
// Copyright (C) Melnac 2017
// v1.0.0
// ************************************************************************
// Utilities classes for ADO.NET Extension...
// ************************************************************************
namespace DAL.ADO.Utilities
{

using System.Data;
using GrayParrot.Data.ADONET;

    // ************************************************************************
    // Utility classes for ADO.NET Extension...
    public class AlphabeticalListOfProductAggregateRoot
	{
          public int ProductId {get; set;}
          public string ProductName {get; set;}
          public bool Discontinued {get; set;}
          public string CategoryName {get; set;}
	}

    public static class AlphabeticalListOfProduct_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Alphabetical list of products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, CategoryName) VALUES (@ProductID, @ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued, @CategoryName)";
       public const string UpdateCmd = "UPDATE dbo.Alphabetical list of products SET ProductID = @ProductId, ProductName = @ProductName, SupplierID = @SupplierId, CategoryID = @CategoryId, QuantityPerUnit = @QuantityPerUnit, UnitPrice = @UnitPrice, UnitsInStock = @UnitsInStock, UnitsOnOrder = @UnitsOnOrder, ReorderLevel = @ReorderLevel, Discontinued = @Discontinued, CategoryName = @CategoryName WHERE ProductID = @ProductId AND ProductName = @ProductName AND Discontinued = @Discontinued AND CategoryName = @CategoryName";
	   public const string RemoveCmd = "DELETE FROM dbo.Alphabetical list of products WHERE ProductID = @ProductId AND ProductName = @ProductName AND Discontinued = @Discontinued AND CategoryName = @CategoryName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Alphabetical list of products WHERE ProductID = @ProductId AND ProductName = @ProductName AND Discontinued = @Discontinued AND CategoryName = @CategoryName";
	   public const string FindCmd = "SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, CategoryName FROM dbo.Alphabetical list of products WHERE ProductID = @ProductId AND ProductName = @ProductName AND Discontinued = @Discontinued AND CategoryName = @CategoryName";
	   public const string FindAllCmd = "SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, CategoryName FROM dbo.Alphabetical list of products";

	   public static void Add(this IDbCommand command, AlphabeticalListOfProduct item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("SupplierId", item.SupplierId);
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("UnitsOnOrder", item.UnitsOnOrder);
          command.AddParameter("ReorderLevel", item.ReorderLevel);
          command.AddParameter("Discontinued", item.Discontinued);
          command.AddParameter("CategoryName", item.CategoryName);
       }

	   public static void Update(this IDbCommand command, AlphabeticalListOfProduct item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("SupplierId", item.SupplierId);
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("UnitsOnOrder", item.UnitsOnOrder);
          command.AddParameter("ReorderLevel", item.ReorderLevel);
          command.AddParameter("Discontinued", item.Discontinued);
          command.AddParameter("CategoryName", item.CategoryName);
       }

	   public static void Remove(this IDbCommand command, AlphabeticalListOfProduct item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("Discontinued", item.Discontinued);
          command.AddParameter("CategoryName", item.CategoryName);
       }

	   public static void RemoveByKey_AlphabeticalListOfProduct(this IDbCommand command, AlphabeticalListOfProductAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("Discontinued", key.Discontinued);
          command.AddParameter("CategoryName", key.CategoryName);
       }

	   public static void Find_AlphabeticalListOfProduct(this IDbCommand command, AlphabeticalListOfProductAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("Discontinued", key.Discontinued);
          command.AddParameter("CategoryName", key.CategoryName);
       }

	   public static void Map_AlphabeticalListOfProduct(this IDataRecord record, AlphabeticalListOfProduct entity)
       {
          entity.ProductId = (!record.IsDBNull(0) ? (int)record["ProductID"] : default(int)); 
          entity.ProductName = (!record.IsDBNull(1) ? (string)record["ProductName"] : default(string)); 
          entity.SupplierId = (!record.IsDBNull(2) ? (int)record["SupplierID"] : default(int)); 
          entity.CategoryId = (!record.IsDBNull(3) ? (int)record["CategoryID"] : default(int)); 
          entity.QuantityPerUnit = (!record.IsDBNull(4) ? (string)record["QuantityPerUnit"] : default(string)); 
          entity.UnitPrice = (!record.IsDBNull(5) ? (decimal)record["UnitPrice"] : default(decimal)); 
          entity.UnitsInStock = (!record.IsDBNull(6) ? (short)record["UnitsInStock"] : default(short)); 
          entity.UnitsOnOrder = (!record.IsDBNull(7) ? (short)record["UnitsOnOrder"] : default(short)); 
          entity.ReorderLevel = (!record.IsDBNull(8) ? (short)record["ReorderLevel"] : default(short)); 
          entity.Discontinued = (!record.IsDBNull(9) ? (bool)record["Discontinued"] : default(bool)); 
          entity.CategoryName = (!record.IsDBNull(10) ? (string)record["CategoryName"] : default(string)); 
       }
	}

    public class CategoryAggregateRoot
	{
          public int CategoryId {get; set;}
	}

    public static class Category_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Categories (CategoryName, Description, Picture) VALUES (@CategoryName, @Description, @Picture)";
       public const string UpdateCmd = "UPDATE dbo.Categories SET CategoryName = @CategoryName, Description = @Description, Picture = @Picture WHERE CategoryID = @CategoryId";
	   public const string RemoveCmd = "DELETE FROM dbo.Categories WHERE CategoryID = @CategoryId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Categories WHERE CategoryID = @CategoryId";
	   public const string FindCmd = "SELECT CategoryName, Description, Picture FROM dbo.Categories WHERE CategoryID = @CategoryId";
	   public const string FindAllCmd = "SELECT CategoryName, Description, Picture FROM dbo.Categories";

	   public static void Add(this IDbCommand command, Category item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("Description", item.Description);
          command.AddParameter("Picture", item.Picture);
       }

	   public static void Update(this IDbCommand command, Category item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("Description", item.Description);
          command.AddParameter("Picture", item.Picture);
       }

	   public static void Remove(this IDbCommand command, Category item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CategoryId", item.CategoryId);
       }

	   public static void RemoveByKey_Category(this IDbCommand command, CategoryAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CategoryId", key.CategoryId);
       }

	   public static void Find_Category(this IDbCommand command, CategoryAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CategoryId", key.CategoryId);
       }

	   public static void Map_Category(this IDataRecord record, Category entity)
       {
          entity.CategoryId = (!record.IsDBNull(0) ? (int)record["CategoryID"] : default(int)); 
          entity.CategoryName = (!record.IsDBNull(1) ? (string)record["CategoryName"] : default(string)); 
          entity.Description = (!record.IsDBNull(2) ? (string)record["Description"] : default(string)); 
          entity.Picture = (!record.IsDBNull(3) ? (byte[])record["Picture"] : default(byte[])); 
       }
	}

    public class CategorySalesFor1997AggregateRoot
	{
          public string CategoryName {get; set;}
	}

    public static class CategorySalesFor1997_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Category Sales for 1997 (CategoryName, CategorySales) VALUES (@CategoryName, @CategorySales)";
       public const string UpdateCmd = "UPDATE dbo.Category Sales for 1997 SET CategoryName = @CategoryName, CategorySales = @CategorySales WHERE CategoryName = @CategoryName";
	   public const string RemoveCmd = "DELETE FROM dbo.Category Sales for 1997 WHERE CategoryName = @CategoryName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Category Sales for 1997 WHERE CategoryName = @CategoryName";
	   public const string FindCmd = "SELECT CategoryName, CategorySales FROM dbo.Category Sales for 1997 WHERE CategoryName = @CategoryName";
	   public const string FindAllCmd = "SELECT CategoryName, CategorySales FROM dbo.Category Sales for 1997";

	   public static void Add(this IDbCommand command, CategorySalesFor1997 item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("CategorySales", item.CategorySales);
       }

	   public static void Update(this IDbCommand command, CategorySalesFor1997 item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("CategorySales", item.CategorySales);
       }

	   public static void Remove(this IDbCommand command, CategorySalesFor1997 item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CategoryName", item.CategoryName);
       }

	   public static void RemoveByKey_CategorySalesFor1997(this IDbCommand command, CategorySalesFor1997AggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CategoryName", key.CategoryName);
       }

	   public static void Find_CategorySalesFor1997(this IDbCommand command, CategorySalesFor1997AggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CategoryName", key.CategoryName);
       }

	   public static void Map_CategorySalesFor1997(this IDataRecord record, CategorySalesFor1997 entity)
       {
          entity.CategoryName = (!record.IsDBNull(0) ? (string)record["CategoryName"] : default(string)); 
          entity.CategorySales = (!record.IsDBNull(1) ? (decimal)record["CategorySales"] : default(decimal)); 
       }
	}

    public class CurrentProductListAggregateRoot
	{
          public int ProductId {get; set;}
          public string ProductName {get; set;}
	}

    public static class CurrentProductList_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Current Product List (ProductName) VALUES (@ProductName)";
       public const string UpdateCmd = "UPDATE dbo.Current Product List SET ProductName = @ProductName WHERE ProductID = @ProductId AND ProductName = @ProductName";
	   public const string RemoveCmd = "DELETE FROM dbo.Current Product List WHERE ProductID = @ProductId AND ProductName = @ProductName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Current Product List WHERE ProductID = @ProductId AND ProductName = @ProductName";
	   public const string FindCmd = "SELECT ProductName FROM dbo.Current Product List WHERE ProductID = @ProductId AND ProductName = @ProductName";
	   public const string FindAllCmd = "SELECT ProductName FROM dbo.Current Product List";

	   public static void Add(this IDbCommand command, CurrentProductList item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void Update(this IDbCommand command, CurrentProductList item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void Remove(this IDbCommand command, CurrentProductList item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void RemoveByKey_CurrentProductList(this IDbCommand command, CurrentProductListAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Find_CurrentProductList(this IDbCommand command, CurrentProductListAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Map_CurrentProductList(this IDataRecord record, CurrentProductList entity)
       {
          entity.ProductId = (!record.IsDBNull(0) ? (int)record["ProductID"] : default(int)); 
          entity.ProductName = (!record.IsDBNull(1) ? (string)record["ProductName"] : default(string)); 
       }
	}

    public class CustomerAggregateRoot
	{
          public string CustomerId {get; set;}
	}

    public static class Customer_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Customers (CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax) VALUES (@CustomerID, @CompanyName, @ContactName, @ContactTitle, @Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax)";
       public const string UpdateCmd = "UPDATE dbo.Customers SET CustomerID = @CustomerId, CompanyName = @CompanyName, ContactName = @ContactName, ContactTitle = @ContactTitle, Address = @Address, City = @City, Region = @Region, PostalCode = @PostalCode, Country = @Country, Phone = @Phone, Fax = @Fax WHERE CustomerID = @CustomerId";
	   public const string RemoveCmd = "DELETE FROM dbo.Customers WHERE CustomerID = @CustomerId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Customers WHERE CustomerID = @CustomerId";
	   public const string FindCmd = "SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax FROM dbo.Customers WHERE CustomerID = @CustomerId";
	   public const string FindAllCmd = "SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax FROM dbo.Customers";

	   public static void Add(this IDbCommand command, Customer item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("ContactTitle", item.ContactTitle);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Phone", item.Phone);
          command.AddParameter("Fax", item.Fax);
       }

	   public static void Update(this IDbCommand command, Customer item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("ContactTitle", item.ContactTitle);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Phone", item.Phone);
          command.AddParameter("Fax", item.Fax);
       }

	   public static void Remove(this IDbCommand command, Customer item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CustomerId", item.CustomerId);
       }

	   public static void RemoveByKey_Customer(this IDbCommand command, CustomerAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CustomerId", key.CustomerId);
       }

	   public static void Find_Customer(this IDbCommand command, CustomerAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CustomerId", key.CustomerId);
       }

	   public static void Map_Customer(this IDataRecord record, Customer entity)
       {
          entity.CustomerId = (!record.IsDBNull(0) ? (string)record["CustomerID"] : default(string)); 
          entity.CompanyName = (!record.IsDBNull(1) ? (string)record["CompanyName"] : default(string)); 
          entity.ContactName = (!record.IsDBNull(2) ? (string)record["ContactName"] : default(string)); 
          entity.ContactTitle = (!record.IsDBNull(3) ? (string)record["ContactTitle"] : default(string)); 
          entity.Address = (!record.IsDBNull(4) ? (string)record["Address"] : default(string)); 
          entity.City = (!record.IsDBNull(5) ? (string)record["City"] : default(string)); 
          entity.Region = (!record.IsDBNull(6) ? (string)record["Region"] : default(string)); 
          entity.PostalCode = (!record.IsDBNull(7) ? (string)record["PostalCode"] : default(string)); 
          entity.Country = (!record.IsDBNull(8) ? (string)record["Country"] : default(string)); 
          entity.Phone = (!record.IsDBNull(9) ? (string)record["Phone"] : default(string)); 
          entity.Fax = (!record.IsDBNull(10) ? (string)record["Fax"] : default(string)); 
       }
	}

    public class CustomerAndSuppliersByCityAggregateRoot
	{
          public string CompanyName {get; set;}
          public string Relationship {get; set;}
	}

    public static class CustomerAndSuppliersByCity_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Customer and Suppliers by City (City, CompanyName, ContactName, Relationship) VALUES (@City, @CompanyName, @ContactName, @Relationship)";
       public const string UpdateCmd = "UPDATE dbo.Customer and Suppliers by City SET City = @City, CompanyName = @CompanyName, ContactName = @ContactName, Relationship = @Relationship WHERE CompanyName = @CompanyName AND Relationship = @Relationship";
	   public const string RemoveCmd = "DELETE FROM dbo.Customer and Suppliers by City WHERE CompanyName = @CompanyName AND Relationship = @Relationship";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Customer and Suppliers by City WHERE CompanyName = @CompanyName AND Relationship = @Relationship";
	   public const string FindCmd = "SELECT City, CompanyName, ContactName, Relationship FROM dbo.Customer and Suppliers by City WHERE CompanyName = @CompanyName AND Relationship = @Relationship";
	   public const string FindAllCmd = "SELECT City, CompanyName, ContactName, Relationship FROM dbo.Customer and Suppliers by City";

	   public static void Add(this IDbCommand command, CustomerAndSuppliersByCity item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("City", item.City);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("Relationship", item.Relationship);
       }

	   public static void Update(this IDbCommand command, CustomerAndSuppliersByCity item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("City", item.City);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("Relationship", item.Relationship);
       }

	   public static void Remove(this IDbCommand command, CustomerAndSuppliersByCity item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("Relationship", item.Relationship);
       }

	   public static void RemoveByKey_CustomerAndSuppliersByCity(this IDbCommand command, CustomerAndSuppliersByCityAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CompanyName", key.CompanyName);
          command.AddParameter("Relationship", key.Relationship);
       }

	   public static void Find_CustomerAndSuppliersByCity(this IDbCommand command, CustomerAndSuppliersByCityAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CompanyName", key.CompanyName);
          command.AddParameter("Relationship", key.Relationship);
       }

	   public static void Map_CustomerAndSuppliersByCity(this IDataRecord record, CustomerAndSuppliersByCity entity)
       {
          entity.City = (!record.IsDBNull(0) ? (string)record["City"] : default(string)); 
          entity.CompanyName = (!record.IsDBNull(1) ? (string)record["CompanyName"] : default(string)); 
          entity.ContactName = (!record.IsDBNull(2) ? (string)record["ContactName"] : default(string)); 
          entity.Relationship = (!record.IsDBNull(3) ? (string)record["Relationship"] : default(string)); 
       }
	}

    public class CustomerDemographicAggregateRoot
	{
          public string CustomerTypeId {get; set;}
	}

    public static class CustomerDemographic_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.CustomerDemographics (CustomerTypeID, CustomerDesc) VALUES (@CustomerTypeID, @CustomerDesc)";
       public const string UpdateCmd = "UPDATE dbo.CustomerDemographics SET CustomerTypeID = @CustomerTypeId, CustomerDesc = @CustomerDesc WHERE CustomerTypeID = @CustomerTypeId";
	   public const string RemoveCmd = "DELETE FROM dbo.CustomerDemographics WHERE CustomerTypeID = @CustomerTypeId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.CustomerDemographics WHERE CustomerTypeID = @CustomerTypeId";
	   public const string FindCmd = "SELECT CustomerTypeID, CustomerDesc FROM dbo.CustomerDemographics WHERE CustomerTypeID = @CustomerTypeId";
	   public const string FindAllCmd = "SELECT CustomerTypeID, CustomerDesc FROM dbo.CustomerDemographics";

	   public static void Add(this IDbCommand command, CustomerDemographic item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CustomerTypeId", item.CustomerTypeId);
          command.AddParameter("CustomerDesc", item.CustomerDesc);
       }

	   public static void Update(this IDbCommand command, CustomerDemographic item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CustomerTypeId", item.CustomerTypeId);
          command.AddParameter("CustomerDesc", item.CustomerDesc);
       }

	   public static void Remove(this IDbCommand command, CustomerDemographic item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CustomerTypeId", item.CustomerTypeId);
       }

	   public static void RemoveByKey_CustomerDemographic(this IDbCommand command, CustomerDemographicAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CustomerTypeId", key.CustomerTypeId);
       }

	   public static void Find_CustomerDemographic(this IDbCommand command, CustomerDemographicAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CustomerTypeId", key.CustomerTypeId);
       }

	   public static void Map_CustomerDemographic(this IDataRecord record, CustomerDemographic entity)
       {
          entity.CustomerTypeId = (!record.IsDBNull(0) ? (string)record["CustomerTypeID"] : default(string)); 
          entity.CustomerDesc = (!record.IsDBNull(1) ? (string)record["CustomerDesc"] : default(string)); 
       }
	}

    public class EmployeeAggregateRoot
	{
          public int EmployeeId {get; set;}
	}

    public static class Employee_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Employees (LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath) VALUES (@LastName, @FirstName, @Title, @TitleOfCourtesy, @BirthDate, @HireDate, @Address, @City, @Region, @PostalCode, @Country, @HomePhone, @Extension, @Photo, @Notes, @ReportsTo, @PhotoPath)";
       public const string UpdateCmd = "UPDATE dbo.Employees SET LastName = @LastName, FirstName = @FirstName, Title = @Title, TitleOfCourtesy = @TitleOfCourtesy, BirthDate = @BirthDate, HireDate = @HireDate, Address = @Address, City = @City, Region = @Region, PostalCode = @PostalCode, Country = @Country, HomePhone = @HomePhone, Extension = @Extension, Photo = @Photo, Notes = @Notes, ReportsTo = @ReportsTo, PhotoPath = @PhotoPath WHERE EmployeeID = @EmployeeId";
	   public const string RemoveCmd = "DELETE FROM dbo.Employees WHERE EmployeeID = @EmployeeId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Employees WHERE EmployeeID = @EmployeeId";
	   public const string FindCmd = "SELECT LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath FROM dbo.Employees WHERE EmployeeID = @EmployeeId";
	   public const string FindAllCmd = "SELECT LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath FROM dbo.Employees";

	   public static void Add(this IDbCommand command, Employee item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("LastName", item.LastName);
          command.AddParameter("FirstName", item.FirstName);
          command.AddParameter("Title", item.Title);
          command.AddParameter("TitleOfCourtesy", item.TitleOfCourtesy);
          command.AddParameter("BirthDate", item.BirthDate);
          command.AddParameter("HireDate", item.HireDate);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("HomePhone", item.HomePhone);
          command.AddParameter("Extension", item.Extension);
          command.AddParameter("Photo", item.Photo);
          command.AddParameter("Notes", item.Notes);
          command.AddParameter("ReportsTo", item.ReportsTo);
          command.AddParameter("PhotoPath", item.PhotoPath);
       }

	   public static void Update(this IDbCommand command, Employee item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("LastName", item.LastName);
          command.AddParameter("FirstName", item.FirstName);
          command.AddParameter("Title", item.Title);
          command.AddParameter("TitleOfCourtesy", item.TitleOfCourtesy);
          command.AddParameter("BirthDate", item.BirthDate);
          command.AddParameter("HireDate", item.HireDate);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("HomePhone", item.HomePhone);
          command.AddParameter("Extension", item.Extension);
          command.AddParameter("Photo", item.Photo);
          command.AddParameter("Notes", item.Notes);
          command.AddParameter("ReportsTo", item.ReportsTo);
          command.AddParameter("PhotoPath", item.PhotoPath);
       }

	   public static void Remove(this IDbCommand command, Employee item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("EmployeeId", item.EmployeeId);
       }

	   public static void RemoveByKey_Employee(this IDbCommand command, EmployeeAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("EmployeeId", key.EmployeeId);
       }

	   public static void Find_Employee(this IDbCommand command, EmployeeAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("EmployeeId", key.EmployeeId);
       }

	   public static void Map_Employee(this IDataRecord record, Employee entity)
       {
          entity.EmployeeId = (!record.IsDBNull(0) ? (int)record["EmployeeID"] : default(int)); 
          entity.LastName = (!record.IsDBNull(1) ? (string)record["LastName"] : default(string)); 
          entity.FirstName = (!record.IsDBNull(2) ? (string)record["FirstName"] : default(string)); 
          entity.Title = (!record.IsDBNull(3) ? (string)record["Title"] : default(string)); 
          entity.TitleOfCourtesy = (!record.IsDBNull(4) ? (string)record["TitleOfCourtesy"] : default(string)); 
          entity.BirthDate = (!record.IsDBNull(5) ? (System.DateTime)record["BirthDate"] : default(System.DateTime)); 
          entity.HireDate = (!record.IsDBNull(6) ? (System.DateTime)record["HireDate"] : default(System.DateTime)); 
          entity.Address = (!record.IsDBNull(7) ? (string)record["Address"] : default(string)); 
          entity.City = (!record.IsDBNull(8) ? (string)record["City"] : default(string)); 
          entity.Region = (!record.IsDBNull(9) ? (string)record["Region"] : default(string)); 
          entity.PostalCode = (!record.IsDBNull(10) ? (string)record["PostalCode"] : default(string)); 
          entity.Country = (!record.IsDBNull(11) ? (string)record["Country"] : default(string)); 
          entity.HomePhone = (!record.IsDBNull(12) ? (string)record["HomePhone"] : default(string)); 
          entity.Extension = (!record.IsDBNull(13) ? (string)record["Extension"] : default(string)); 
          entity.Photo = (!record.IsDBNull(14) ? (byte[])record["Photo"] : default(byte[])); 
          entity.Notes = (!record.IsDBNull(15) ? (string)record["Notes"] : default(string)); 
          entity.ReportsTo = (!record.IsDBNull(16) ? (int)record["ReportsTo"] : default(int)); 
          entity.PhotoPath = (!record.IsDBNull(17) ? (string)record["PhotoPath"] : default(string)); 
       }
	}

    public class InvoiceAggregateRoot
	{
          public string CustomerName {get; set;}
          public string Salesperson {get; set;}
          public int OrderId {get; set;}
          public string ShipperName {get; set;}
          public int ProductId {get; set;}
          public string ProductName {get; set;}
          public decimal UnitPrice {get; set;}
          public short Quantity {get; set;}
          public float Discount {get; set;}
	}

    public static class Invoice_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Invoices (ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CustomerID, CustomerName, Address, City, Region, PostalCode, Country, Salesperson, OrderID, OrderDate, RequiredDate, ShippedDate, ShipperName, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice, Freight) VALUES (@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry, @CustomerID, @CustomerName, @Address, @City, @Region, @PostalCode, @Country, @Salesperson, @OrderID, @OrderDate, @RequiredDate, @ShippedDate, @ShipperName, @ProductID, @ProductName, @UnitPrice, @Quantity, @Discount, @ExtendedPrice, @Freight)";
       public const string UpdateCmd = "UPDATE dbo.Invoices SET ShipName = @ShipName, ShipAddress = @ShipAddress, ShipCity = @ShipCity, ShipRegion = @ShipRegion, ShipPostalCode = @ShipPostalCode, ShipCountry = @ShipCountry, CustomerID = @CustomerId, CustomerName = @CustomerName, Address = @Address, City = @City, Region = @Region, PostalCode = @PostalCode, Country = @Country, Salesperson = @Salesperson, OrderID = @OrderId, OrderDate = @OrderDate, RequiredDate = @RequiredDate, ShippedDate = @ShippedDate, ShipperName = @ShipperName, ProductID = @ProductId, ProductName = @ProductName, UnitPrice = @UnitPrice, Quantity = @Quantity, Discount = @Discount, ExtendedPrice = @ExtendedPrice, Freight = @Freight WHERE CustomerName = @CustomerName AND Salesperson = @Salesperson AND OrderID = @OrderId AND ShipperName = @ShipperName AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string RemoveCmd = "DELETE FROM dbo.Invoices WHERE CustomerName = @CustomerName AND Salesperson = @Salesperson AND OrderID = @OrderId AND ShipperName = @ShipperName AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Invoices WHERE CustomerName = @CustomerName AND Salesperson = @Salesperson AND OrderID = @OrderId AND ShipperName = @ShipperName AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string FindCmd = "SELECT ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CustomerID, CustomerName, Address, City, Region, PostalCode, Country, Salesperson, OrderID, OrderDate, RequiredDate, ShippedDate, ShipperName, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice, Freight FROM dbo.Invoices WHERE CustomerName = @CustomerName AND Salesperson = @Salesperson AND OrderID = @OrderId AND ShipperName = @ShipperName AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string FindAllCmd = "SELECT ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CustomerID, CustomerName, Address, City, Region, PostalCode, Country, Salesperson, OrderID, OrderDate, RequiredDate, ShippedDate, ShipperName, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice, Freight FROM dbo.Invoices";

	   public static void Add(this IDbCommand command, Invoice item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CustomerName", item.CustomerName);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Salesperson", item.Salesperson);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipperName", item.ShipperName);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
          command.AddParameter("ExtendedPrice", item.ExtendedPrice);
          command.AddParameter("Freight", item.Freight);
       }

	   public static void Update(this IDbCommand command, Invoice item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CustomerName", item.CustomerName);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Salesperson", item.Salesperson);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipperName", item.ShipperName);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
          command.AddParameter("ExtendedPrice", item.ExtendedPrice);
          command.AddParameter("Freight", item.Freight);
       }

	   public static void Remove(this IDbCommand command, Invoice item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CustomerName", item.CustomerName);
          command.AddParameter("Salesperson", item.Salesperson);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ShipperName", item.ShipperName);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
       }

	   public static void RemoveByKey_Invoice(this IDbCommand command, InvoiceAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CustomerName", key.CustomerName);
          command.AddParameter("Salesperson", key.Salesperson);
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ShipperName", key.ShipperName);
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("UnitPrice", key.UnitPrice);
          command.AddParameter("Quantity", key.Quantity);
          command.AddParameter("Discount", key.Discount);
       }

	   public static void Find_Invoice(this IDbCommand command, InvoiceAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CustomerName", key.CustomerName);
          command.AddParameter("Salesperson", key.Salesperson);
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ShipperName", key.ShipperName);
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("UnitPrice", key.UnitPrice);
          command.AddParameter("Quantity", key.Quantity);
          command.AddParameter("Discount", key.Discount);
       }

	   public static void Map_Invoice(this IDataRecord record, Invoice entity)
       {
          entity.ShipName = (!record.IsDBNull(0) ? (string)record["ShipName"] : default(string)); 
          entity.ShipAddress = (!record.IsDBNull(1) ? (string)record["ShipAddress"] : default(string)); 
          entity.ShipCity = (!record.IsDBNull(2) ? (string)record["ShipCity"] : default(string)); 
          entity.ShipRegion = (!record.IsDBNull(3) ? (string)record["ShipRegion"] : default(string)); 
          entity.ShipPostalCode = (!record.IsDBNull(4) ? (string)record["ShipPostalCode"] : default(string)); 
          entity.ShipCountry = (!record.IsDBNull(5) ? (string)record["ShipCountry"] : default(string)); 
          entity.CustomerId = (!record.IsDBNull(6) ? (string)record["CustomerID"] : default(string)); 
          entity.CustomerName = (!record.IsDBNull(7) ? (string)record["CustomerName"] : default(string)); 
          entity.Address = (!record.IsDBNull(8) ? (string)record["Address"] : default(string)); 
          entity.City = (!record.IsDBNull(9) ? (string)record["City"] : default(string)); 
          entity.Region = (!record.IsDBNull(10) ? (string)record["Region"] : default(string)); 
          entity.PostalCode = (!record.IsDBNull(11) ? (string)record["PostalCode"] : default(string)); 
          entity.Country = (!record.IsDBNull(12) ? (string)record["Country"] : default(string)); 
          entity.Salesperson = (!record.IsDBNull(13) ? (string)record["Salesperson"] : default(string)); 
          entity.OrderId = (!record.IsDBNull(14) ? (int)record["OrderID"] : default(int)); 
          entity.OrderDate = (!record.IsDBNull(15) ? (System.DateTime)record["OrderDate"] : default(System.DateTime)); 
          entity.RequiredDate = (!record.IsDBNull(16) ? (System.DateTime)record["RequiredDate"] : default(System.DateTime)); 
          entity.ShippedDate = (!record.IsDBNull(17) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
          entity.ShipperName = (!record.IsDBNull(18) ? (string)record["ShipperName"] : default(string)); 
          entity.ProductId = (!record.IsDBNull(19) ? (int)record["ProductID"] : default(int)); 
          entity.ProductName = (!record.IsDBNull(20) ? (string)record["ProductName"] : default(string)); 
          entity.UnitPrice = (!record.IsDBNull(21) ? (decimal)record["UnitPrice"] : default(decimal)); 
          entity.Quantity = (!record.IsDBNull(22) ? (short)record["Quantity"] : default(short)); 
          entity.Discount = (!record.IsDBNull(23) ? (float)record["Discount"] : default(float)); 
          entity.ExtendedPrice = (!record.IsDBNull(24) ? (decimal)record["ExtendedPrice"] : default(decimal)); 
          entity.Freight = (!record.IsDBNull(25) ? (decimal)record["Freight"] : default(decimal)); 
       }
	}

    public class OrderAggregateRoot
	{
          public int OrderId {get; set;}
	}

    public static class Order_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Orders (CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry) VALUES (@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight, @ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry)";
       public const string UpdateCmd = "UPDATE dbo.Orders SET CustomerID = @CustomerId, EmployeeID = @EmployeeId, OrderDate = @OrderDate, RequiredDate = @RequiredDate, ShippedDate = @ShippedDate, ShipVia = @ShipVia, Freight = @Freight, ShipName = @ShipName, ShipAddress = @ShipAddress, ShipCity = @ShipCity, ShipRegion = @ShipRegion, ShipPostalCode = @ShipPostalCode, ShipCountry = @ShipCountry WHERE OrderID = @OrderId";
	   public const string RemoveCmd = "DELETE FROM dbo.Orders WHERE OrderID = @OrderId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Orders WHERE OrderID = @OrderId";
	   public const string FindCmd = "SELECT CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM dbo.Orders WHERE OrderID = @OrderId";
	   public const string FindAllCmd = "SELECT CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM dbo.Orders";

	   public static void Add(this IDbCommand command, Order item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("EmployeeId", item.EmployeeId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipVia", item.ShipVia);
          command.AddParameter("Freight", item.Freight);
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
       }

	   public static void Update(this IDbCommand command, Order item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("EmployeeId", item.EmployeeId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipVia", item.ShipVia);
          command.AddParameter("Freight", item.Freight);
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
       }

	   public static void Remove(this IDbCommand command, Order item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
       }

	   public static void RemoveByKey_Order(this IDbCommand command, OrderAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Find_Order(this IDbCommand command, OrderAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Map_Order(this IDataRecord record, Order entity)
       {
          entity.OrderId = (!record.IsDBNull(0) ? (int)record["OrderID"] : default(int)); 
          entity.CustomerId = (!record.IsDBNull(1) ? (string)record["CustomerID"] : default(string)); 
          entity.EmployeeId = (!record.IsDBNull(2) ? (int)record["EmployeeID"] : default(int)); 
          entity.OrderDate = (!record.IsDBNull(3) ? (System.DateTime)record["OrderDate"] : default(System.DateTime)); 
          entity.RequiredDate = (!record.IsDBNull(4) ? (System.DateTime)record["RequiredDate"] : default(System.DateTime)); 
          entity.ShippedDate = (!record.IsDBNull(5) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
          entity.ShipVia = (!record.IsDBNull(6) ? (int)record["ShipVia"] : default(int)); 
          entity.Freight = (!record.IsDBNull(7) ? (decimal)record["Freight"] : default(decimal)); 
          entity.ShipName = (!record.IsDBNull(8) ? (string)record["ShipName"] : default(string)); 
          entity.ShipAddress = (!record.IsDBNull(9) ? (string)record["ShipAddress"] : default(string)); 
          entity.ShipCity = (!record.IsDBNull(10) ? (string)record["ShipCity"] : default(string)); 
          entity.ShipRegion = (!record.IsDBNull(11) ? (string)record["ShipRegion"] : default(string)); 
          entity.ShipPostalCode = (!record.IsDBNull(12) ? (string)record["ShipPostalCode"] : default(string)); 
          entity.ShipCountry = (!record.IsDBNull(13) ? (string)record["ShipCountry"] : default(string)); 
       }
	}

    public class OrderDetailAggregateRoot
	{
          public int OrderId {get; set;}
          public int ProductId {get; set;}
	}

    public static class OrderDetail_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Order Details (OrderID, ProductID, UnitPrice, Quantity, Discount) VALUES (@OrderID, @ProductID, @UnitPrice, @Quantity, @Discount)";
       public const string UpdateCmd = "UPDATE dbo.Order Details SET OrderID = @OrderId, ProductID = @ProductId, UnitPrice = @UnitPrice, Quantity = @Quantity, Discount = @Discount WHERE OrderID = @OrderId AND ProductID = @ProductId";
	   public const string RemoveCmd = "DELETE FROM dbo.Order Details WHERE OrderID = @OrderId AND ProductID = @ProductId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Order Details WHERE OrderID = @OrderId AND ProductID = @ProductId";
	   public const string FindCmd = "SELECT OrderID, ProductID, UnitPrice, Quantity, Discount FROM dbo.Order Details WHERE OrderID = @OrderId AND ProductID = @ProductId";
	   public const string FindAllCmd = "SELECT OrderID, ProductID, UnitPrice, Quantity, Discount FROM dbo.Order Details";

	   public static void Add(this IDbCommand command, OrderDetail item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
       }

	   public static void Update(this IDbCommand command, OrderDetail item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
       }

	   public static void Remove(this IDbCommand command, OrderDetail item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
       }

	   public static void RemoveByKey_OrderDetail(this IDbCommand command, OrderDetailAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ProductId", key.ProductId);
       }

	   public static void Find_OrderDetail(this IDbCommand command, OrderDetailAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ProductId", key.ProductId);
       }

	   public static void Map_OrderDetail(this IDataRecord record, OrderDetail entity)
       {
          entity.OrderId = (!record.IsDBNull(0) ? (int)record["OrderID"] : default(int)); 
          entity.ProductId = (!record.IsDBNull(1) ? (int)record["ProductID"] : default(int)); 
          entity.UnitPrice = (!record.IsDBNull(2) ? (decimal)record["UnitPrice"] : default(decimal)); 
          entity.Quantity = (!record.IsDBNull(3) ? (short)record["Quantity"] : default(short)); 
          entity.Discount = (!record.IsDBNull(4) ? (float)record["Discount"] : default(float)); 
       }
	}

    public class OrderDetailsExtendedAggregateRoot
	{
          public int OrderId {get; set;}
          public int ProductId {get; set;}
          public string ProductName {get; set;}
          public decimal UnitPrice {get; set;}
          public short Quantity {get; set;}
          public float Discount {get; set;}
	}

    public static class OrderDetailsExtended_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Order Details Extended (OrderID, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice) VALUES (@OrderID, @ProductID, @ProductName, @UnitPrice, @Quantity, @Discount, @ExtendedPrice)";
       public const string UpdateCmd = "UPDATE dbo.Order Details Extended SET OrderID = @OrderId, ProductID = @ProductId, ProductName = @ProductName, UnitPrice = @UnitPrice, Quantity = @Quantity, Discount = @Discount, ExtendedPrice = @ExtendedPrice WHERE OrderID = @OrderId AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string RemoveCmd = "DELETE FROM dbo.Order Details Extended WHERE OrderID = @OrderId AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Order Details Extended WHERE OrderID = @OrderId AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string FindCmd = "SELECT OrderID, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice FROM dbo.Order Details Extended WHERE OrderID = @OrderId AND ProductID = @ProductId AND ProductName = @ProductName AND UnitPrice = @UnitPrice AND Quantity = @Quantity AND Discount = @Discount";
	   public const string FindAllCmd = "SELECT OrderID, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice FROM dbo.Order Details Extended";

	   public static void Add(this IDbCommand command, OrderDetailsExtended item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
          command.AddParameter("ExtendedPrice", item.ExtendedPrice);
       }

	   public static void Update(this IDbCommand command, OrderDetailsExtended item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
          command.AddParameter("ExtendedPrice", item.ExtendedPrice);
       }

	   public static void Remove(this IDbCommand command, OrderDetailsExtended item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("ProductId", item.ProductId);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("Quantity", item.Quantity);
          command.AddParameter("Discount", item.Discount);
       }

	   public static void RemoveByKey_OrderDetailsExtended(this IDbCommand command, OrderDetailsExtendedAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("UnitPrice", key.UnitPrice);
          command.AddParameter("Quantity", key.Quantity);
          command.AddParameter("Discount", key.Discount);
       }

	   public static void Find_OrderDetailsExtended(this IDbCommand command, OrderDetailsExtendedAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("ProductId", key.ProductId);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("UnitPrice", key.UnitPrice);
          command.AddParameter("Quantity", key.Quantity);
          command.AddParameter("Discount", key.Discount);
       }

	   public static void Map_OrderDetailsExtended(this IDataRecord record, OrderDetailsExtended entity)
       {
          entity.OrderId = (!record.IsDBNull(0) ? (int)record["OrderID"] : default(int)); 
          entity.ProductId = (!record.IsDBNull(1) ? (int)record["ProductID"] : default(int)); 
          entity.ProductName = (!record.IsDBNull(2) ? (string)record["ProductName"] : default(string)); 
          entity.UnitPrice = (!record.IsDBNull(3) ? (decimal)record["UnitPrice"] : default(decimal)); 
          entity.Quantity = (!record.IsDBNull(4) ? (short)record["Quantity"] : default(short)); 
          entity.Discount = (!record.IsDBNull(5) ? (float)record["Discount"] : default(float)); 
          entity.ExtendedPrice = (!record.IsDBNull(6) ? (decimal)record["ExtendedPrice"] : default(decimal)); 
       }
	}

    public class OrdersQryAggregateRoot
	{
          public int OrderId {get; set;}
          public string CompanyName {get; set;}
	}

    public static class OrdersQry_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Orders Qry (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CompanyName, Address, City, Region, PostalCode, Country) VALUES (@OrderID, @CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight, @ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry, @CompanyName, @Address, @City, @Region, @PostalCode, @Country)";
       public const string UpdateCmd = "UPDATE dbo.Orders Qry SET OrderID = @OrderId, CustomerID = @CustomerId, EmployeeID = @EmployeeId, OrderDate = @OrderDate, RequiredDate = @RequiredDate, ShippedDate = @ShippedDate, ShipVia = @ShipVia, Freight = @Freight, ShipName = @ShipName, ShipAddress = @ShipAddress, ShipCity = @ShipCity, ShipRegion = @ShipRegion, ShipPostalCode = @ShipPostalCode, ShipCountry = @ShipCountry, CompanyName = @CompanyName, Address = @Address, City = @City, Region = @Region, PostalCode = @PostalCode, Country = @Country WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string RemoveCmd = "DELETE FROM dbo.Orders Qry WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Orders Qry WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string FindCmd = "SELECT OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CompanyName, Address, City, Region, PostalCode, Country FROM dbo.Orders Qry WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string FindAllCmd = "SELECT OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry, CompanyName, Address, City, Region, PostalCode, Country FROM dbo.Orders Qry";

	   public static void Add(this IDbCommand command, OrdersQry item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("EmployeeId", item.EmployeeId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipVia", item.ShipVia);
          command.AddParameter("Freight", item.Freight);
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
       }

	   public static void Update(this IDbCommand command, OrdersQry item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("EmployeeId", item.EmployeeId);
          command.AddParameter("OrderDate", item.OrderDate);
          command.AddParameter("RequiredDate", item.RequiredDate);
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("ShipVia", item.ShipVia);
          command.AddParameter("Freight", item.Freight);
          command.AddParameter("ShipName", item.ShipName);
          command.AddParameter("ShipAddress", item.ShipAddress);
          command.AddParameter("ShipCity", item.ShipCity);
          command.AddParameter("ShipRegion", item.ShipRegion);
          command.AddParameter("ShipPostalCode", item.ShipPostalCode);
          command.AddParameter("ShipCountry", item.ShipCountry);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
       }

	   public static void Remove(this IDbCommand command, OrdersQry item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CompanyName", item.CompanyName);
       }

	   public static void RemoveByKey_OrdersQry(this IDbCommand command, OrdersQryAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("CompanyName", key.CompanyName);
       }

	   public static void Find_OrdersQry(this IDbCommand command, OrdersQryAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("CompanyName", key.CompanyName);
       }

	   public static void Map_OrdersQry(this IDataRecord record, OrdersQry entity)
       {
          entity.OrderId = (!record.IsDBNull(0) ? (int)record["OrderID"] : default(int)); 
          entity.CustomerId = (!record.IsDBNull(1) ? (string)record["CustomerID"] : default(string)); 
          entity.EmployeeId = (!record.IsDBNull(2) ? (int)record["EmployeeID"] : default(int)); 
          entity.OrderDate = (!record.IsDBNull(3) ? (System.DateTime)record["OrderDate"] : default(System.DateTime)); 
          entity.RequiredDate = (!record.IsDBNull(4) ? (System.DateTime)record["RequiredDate"] : default(System.DateTime)); 
          entity.ShippedDate = (!record.IsDBNull(5) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
          entity.ShipVia = (!record.IsDBNull(6) ? (int)record["ShipVia"] : default(int)); 
          entity.Freight = (!record.IsDBNull(7) ? (decimal)record["Freight"] : default(decimal)); 
          entity.ShipName = (!record.IsDBNull(8) ? (string)record["ShipName"] : default(string)); 
          entity.ShipAddress = (!record.IsDBNull(9) ? (string)record["ShipAddress"] : default(string)); 
          entity.ShipCity = (!record.IsDBNull(10) ? (string)record["ShipCity"] : default(string)); 
          entity.ShipRegion = (!record.IsDBNull(11) ? (string)record["ShipRegion"] : default(string)); 
          entity.ShipPostalCode = (!record.IsDBNull(12) ? (string)record["ShipPostalCode"] : default(string)); 
          entity.ShipCountry = (!record.IsDBNull(13) ? (string)record["ShipCountry"] : default(string)); 
          entity.CompanyName = (!record.IsDBNull(14) ? (string)record["CompanyName"] : default(string)); 
          entity.Address = (!record.IsDBNull(15) ? (string)record["Address"] : default(string)); 
          entity.City = (!record.IsDBNull(16) ? (string)record["City"] : default(string)); 
          entity.Region = (!record.IsDBNull(17) ? (string)record["Region"] : default(string)); 
          entity.PostalCode = (!record.IsDBNull(18) ? (string)record["PostalCode"] : default(string)); 
          entity.Country = (!record.IsDBNull(19) ? (string)record["Country"] : default(string)); 
       }
	}

    public class OrderSubtotalAggregateRoot
	{
          public int OrderId {get; set;}
	}

    public static class OrderSubtotal_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Order Subtotals (OrderID, Subtotal) VALUES (@OrderID, @Subtotal)";
       public const string UpdateCmd = "UPDATE dbo.Order Subtotals SET OrderID = @OrderId, Subtotal = @Subtotal WHERE OrderID = @OrderId";
	   public const string RemoveCmd = "DELETE FROM dbo.Order Subtotals WHERE OrderID = @OrderId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Order Subtotals WHERE OrderID = @OrderId";
	   public const string FindCmd = "SELECT OrderID, Subtotal FROM dbo.Order Subtotals WHERE OrderID = @OrderId";
	   public const string FindAllCmd = "SELECT OrderID, Subtotal FROM dbo.Order Subtotals";

	   public static void Add(this IDbCommand command, OrderSubtotal item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Update(this IDbCommand command, OrderSubtotal item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Remove(this IDbCommand command, OrderSubtotal item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
       }

	   public static void RemoveByKey_OrderSubtotal(this IDbCommand command, OrderSubtotalAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Find_OrderSubtotal(this IDbCommand command, OrderSubtotalAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Map_OrderSubtotal(this IDataRecord record, OrderSubtotal entity)
       {
          entity.OrderId = (!record.IsDBNull(0) ? (int)record["OrderID"] : default(int)); 
          entity.Subtotal = (!record.IsDBNull(1) ? (decimal)record["Subtotal"] : default(decimal)); 
       }
	}

    public class ProductAggregateRoot
	{
          public int ProductId {get; set;}
	}

    public static class Product_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Products (ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued) VALUES (@ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued)";
       public const string UpdateCmd = "UPDATE dbo.Products SET ProductName = @ProductName, SupplierID = @SupplierId, CategoryID = @CategoryId, QuantityPerUnit = @QuantityPerUnit, UnitPrice = @UnitPrice, UnitsInStock = @UnitsInStock, UnitsOnOrder = @UnitsOnOrder, ReorderLevel = @ReorderLevel, Discontinued = @Discontinued WHERE ProductID = @ProductId";
	   public const string RemoveCmd = "DELETE FROM dbo.Products WHERE ProductID = @ProductId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Products WHERE ProductID = @ProductId";
	   public const string FindCmd = "SELECT ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM dbo.Products WHERE ProductID = @ProductId";
	   public const string FindAllCmd = "SELECT ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM dbo.Products";

	   public static void Add(this IDbCommand command, Product item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("SupplierId", item.SupplierId);
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("UnitsOnOrder", item.UnitsOnOrder);
          command.AddParameter("ReorderLevel", item.ReorderLevel);
          command.AddParameter("Discontinued", item.Discontinued);
       }

	   public static void Update(this IDbCommand command, Product item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("SupplierId", item.SupplierId);
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitPrice", item.UnitPrice);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("UnitsOnOrder", item.UnitsOnOrder);
          command.AddParameter("ReorderLevel", item.ReorderLevel);
          command.AddParameter("Discontinued", item.Discontinued);
       }

	   public static void Remove(this IDbCommand command, Product item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("ProductId", item.ProductId);
       }

	   public static void RemoveByKey_Product(this IDbCommand command, ProductAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("ProductId", key.ProductId);
       }

	   public static void Find_Product(this IDbCommand command, ProductAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("ProductId", key.ProductId);
       }

	   public static void Map_Product(this IDataRecord record, Product entity)
       {
          entity.ProductId = (!record.IsDBNull(0) ? (int)record["ProductID"] : default(int)); 
          entity.ProductName = (!record.IsDBNull(1) ? (string)record["ProductName"] : default(string)); 
          entity.SupplierId = (!record.IsDBNull(2) ? (int)record["SupplierID"] : default(int)); 
          entity.CategoryId = (!record.IsDBNull(3) ? (int)record["CategoryID"] : default(int)); 
          entity.QuantityPerUnit = (!record.IsDBNull(4) ? (string)record["QuantityPerUnit"] : default(string)); 
          entity.UnitPrice = (!record.IsDBNull(5) ? (decimal)record["UnitPrice"] : default(decimal)); 
          entity.UnitsInStock = (!record.IsDBNull(6) ? (short)record["UnitsInStock"] : default(short)); 
          entity.UnitsOnOrder = (!record.IsDBNull(7) ? (short)record["UnitsOnOrder"] : default(short)); 
          entity.ReorderLevel = (!record.IsDBNull(8) ? (short)record["ReorderLevel"] : default(short)); 
          entity.Discontinued = (!record.IsDBNull(9) ? (bool)record["Discontinued"] : default(bool)); 
       }
	}

    public class ProductsAboveAveragePriceAggregateRoot
	{
          public string ProductName {get; set;}
	}

    public static class ProductsAboveAveragePrice_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Products Above Average Price (ProductName, UnitPrice) VALUES (@ProductName, @UnitPrice)";
       public const string UpdateCmd = "UPDATE dbo.Products Above Average Price SET ProductName = @ProductName, UnitPrice = @UnitPrice WHERE ProductName = @ProductName";
	   public const string RemoveCmd = "DELETE FROM dbo.Products Above Average Price WHERE ProductName = @ProductName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Products Above Average Price WHERE ProductName = @ProductName";
	   public const string FindCmd = "SELECT ProductName, UnitPrice FROM dbo.Products Above Average Price WHERE ProductName = @ProductName";
	   public const string FindAllCmd = "SELECT ProductName, UnitPrice FROM dbo.Products Above Average Price";

	   public static void Add(this IDbCommand command, ProductsAboveAveragePrice item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
       }

	   public static void Update(this IDbCommand command, ProductsAboveAveragePrice item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("UnitPrice", item.UnitPrice);
       }

	   public static void Remove(this IDbCommand command, ProductsAboveAveragePrice item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void RemoveByKey_ProductsAboveAveragePrice(this IDbCommand command, ProductsAboveAveragePriceAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Find_ProductsAboveAveragePrice(this IDbCommand command, ProductsAboveAveragePriceAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Map_ProductsAboveAveragePrice(this IDataRecord record, ProductsAboveAveragePrice entity)
       {
          entity.ProductName = (!record.IsDBNull(0) ? (string)record["ProductName"] : default(string)); 
          entity.UnitPrice = (!record.IsDBNull(1) ? (decimal)record["UnitPrice"] : default(decimal)); 
       }
	}

    public class ProductSalesFor1997AggregateRoot
	{
          public string CategoryName {get; set;}
          public string ProductName {get; set;}
	}

    public static class ProductSalesFor1997_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Product Sales for 1997 (CategoryName, ProductName, ProductSales) VALUES (@CategoryName, @ProductName, @ProductSales)";
       public const string UpdateCmd = "UPDATE dbo.Product Sales for 1997 SET CategoryName = @CategoryName, ProductName = @ProductName, ProductSales = @ProductSales WHERE CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string RemoveCmd = "DELETE FROM dbo.Product Sales for 1997 WHERE CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Product Sales for 1997 WHERE CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string FindCmd = "SELECT CategoryName, ProductName, ProductSales FROM dbo.Product Sales for 1997 WHERE CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string FindAllCmd = "SELECT CategoryName, ProductName, ProductSales FROM dbo.Product Sales for 1997";

	   public static void Add(this IDbCommand command, ProductSalesFor1997 item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("ProductSales", item.ProductSales);
       }

	   public static void Update(this IDbCommand command, ProductSalesFor1997 item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("ProductSales", item.ProductSales);
       }

	   public static void Remove(this IDbCommand command, ProductSalesFor1997 item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void RemoveByKey_ProductSalesFor1997(this IDbCommand command, ProductSalesFor1997AggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Find_ProductSalesFor1997(this IDbCommand command, ProductSalesFor1997AggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Map_ProductSalesFor1997(this IDataRecord record, ProductSalesFor1997 entity)
       {
          entity.CategoryName = (!record.IsDBNull(0) ? (string)record["CategoryName"] : default(string)); 
          entity.ProductName = (!record.IsDBNull(1) ? (string)record["ProductName"] : default(string)); 
          entity.ProductSales = (!record.IsDBNull(2) ? (decimal)record["ProductSales"] : default(decimal)); 
       }
	}

    public class ProductsByCategoryAggregateRoot
	{
          public string CategoryName {get; set;}
          public string ProductName {get; set;}
          public bool Discontinued {get; set;}
	}

    public static class ProductsByCategory_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Products by Category (CategoryName, ProductName, QuantityPerUnit, UnitsInStock, Discontinued) VALUES (@CategoryName, @ProductName, @QuantityPerUnit, @UnitsInStock, @Discontinued)";
       public const string UpdateCmd = "UPDATE dbo.Products by Category SET CategoryName = @CategoryName, ProductName = @ProductName, QuantityPerUnit = @QuantityPerUnit, UnitsInStock = @UnitsInStock, Discontinued = @Discontinued WHERE CategoryName = @CategoryName AND ProductName = @ProductName AND Discontinued = @Discontinued";
	   public const string RemoveCmd = "DELETE FROM dbo.Products by Category WHERE CategoryName = @CategoryName AND ProductName = @ProductName AND Discontinued = @Discontinued";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Products by Category WHERE CategoryName = @CategoryName AND ProductName = @ProductName AND Discontinued = @Discontinued";
	   public const string FindCmd = "SELECT CategoryName, ProductName, QuantityPerUnit, UnitsInStock, Discontinued FROM dbo.Products by Category WHERE CategoryName = @CategoryName AND ProductName = @ProductName AND Discontinued = @Discontinued";
	   public const string FindAllCmd = "SELECT CategoryName, ProductName, QuantityPerUnit, UnitsInStock, Discontinued FROM dbo.Products by Category";

	   public static void Add(this IDbCommand command, ProductsByCategory item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("Discontinued", item.Discontinued);
       }

	   public static void Update(this IDbCommand command, ProductsByCategory item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("QuantityPerUnit", item.QuantityPerUnit);
          command.AddParameter("UnitsInStock", item.UnitsInStock);
          command.AddParameter("Discontinued", item.Discontinued);
       }

	   public static void Remove(this IDbCommand command, ProductsByCategory item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("Discontinued", item.Discontinued);
       }

	   public static void RemoveByKey_ProductsByCategory(this IDbCommand command, ProductsByCategoryAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("Discontinued", key.Discontinued);
       }

	   public static void Find_ProductsByCategory(this IDbCommand command, ProductsByCategoryAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
          command.AddParameter("Discontinued", key.Discontinued);
       }

	   public static void Map_ProductsByCategory(this IDataRecord record, ProductsByCategory entity)
       {
          entity.CategoryName = (!record.IsDBNull(0) ? (string)record["CategoryName"] : default(string)); 
          entity.ProductName = (!record.IsDBNull(1) ? (string)record["ProductName"] : default(string)); 
          entity.QuantityPerUnit = (!record.IsDBNull(2) ? (string)record["QuantityPerUnit"] : default(string)); 
          entity.UnitsInStock = (!record.IsDBNull(3) ? (short)record["UnitsInStock"] : default(short)); 
          entity.Discontinued = (!record.IsDBNull(4) ? (bool)record["Discontinued"] : default(bool)); 
       }
	}

    public class QuarterlyOrderAggregateRoot
	{
	}

    public static class QuarterlyOrder_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Quarterly Orders (CustomerID, CompanyName, City, Country) VALUES (@CustomerID, @CompanyName, @City, @Country)";
       public const string UpdateCmd = "UPDATE dbo.Quarterly Orders SET CustomerID = @CustomerId, CompanyName = @CompanyName, City = @City, Country = @Country WHERE ";
	   public const string RemoveCmd = "DELETE FROM dbo.Quarterly Orders WHERE ";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Quarterly Orders WHERE ";
	   public const string FindCmd = "SELECT CustomerID, CompanyName, City, Country FROM dbo.Quarterly Orders WHERE ";
	   public const string FindAllCmd = "SELECT CustomerID, CompanyName, City, Country FROM dbo.Quarterly Orders";

	   public static void Add(this IDbCommand command, QuarterlyOrder item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("City", item.City);
          command.AddParameter("Country", item.Country);
       }

	   public static void Update(this IDbCommand command, QuarterlyOrder item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CustomerId", item.CustomerId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("City", item.City);
          command.AddParameter("Country", item.Country);
       }

	   public static void Remove(this IDbCommand command, QuarterlyOrder item)
       {
	      command.CommandText = RemoveCmd;
       }

	   public static void RemoveByKey_QuarterlyOrder(this IDbCommand command, QuarterlyOrderAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
       }

	   public static void Find_QuarterlyOrder(this IDbCommand command, QuarterlyOrderAggregateRoot key)
       {
	      command.CommandText = FindCmd;
       }

	   public static void Map_QuarterlyOrder(this IDataRecord record, QuarterlyOrder entity)
       {
          entity.CustomerId = (!record.IsDBNull(0) ? (string)record["CustomerID"] : default(string)); 
          entity.CompanyName = (!record.IsDBNull(1) ? (string)record["CompanyName"] : default(string)); 
          entity.City = (!record.IsDBNull(2) ? (string)record["City"] : default(string)); 
          entity.Country = (!record.IsDBNull(3) ? (string)record["Country"] : default(string)); 
       }
	}

    public class RegionAggregateRoot
	{
          public int RegionId {get; set;}
	}

    public static class Region_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Region (RegionID, RegionDescription) VALUES (@RegionID, @RegionDescription)";
       public const string UpdateCmd = "UPDATE dbo.Region SET RegionID = @RegionId, RegionDescription = @RegionDescription WHERE RegionID = @RegionId";
	   public const string RemoveCmd = "DELETE FROM dbo.Region WHERE RegionID = @RegionId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Region WHERE RegionID = @RegionId";
	   public const string FindCmd = "SELECT RegionID, RegionDescription FROM dbo.Region WHERE RegionID = @RegionId";
	   public const string FindAllCmd = "SELECT RegionID, RegionDescription FROM dbo.Region";

	   public static void Add(this IDbCommand command, Region item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("RegionId", item.RegionId);
          command.AddParameter("RegionDescription", item.RegionDescription);
       }

	   public static void Update(this IDbCommand command, Region item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("RegionId", item.RegionId);
          command.AddParameter("RegionDescription", item.RegionDescription);
       }

	   public static void Remove(this IDbCommand command, Region item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("RegionId", item.RegionId);
       }

	   public static void RemoveByKey_Region(this IDbCommand command, RegionAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("RegionId", key.RegionId);
       }

	   public static void Find_Region(this IDbCommand command, RegionAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("RegionId", key.RegionId);
       }

	   public static void Map_Region(this IDataRecord record, Region entity)
       {
          entity.RegionId = (!record.IsDBNull(0) ? (int)record["RegionID"] : default(int)); 
          entity.RegionDescription = (!record.IsDBNull(1) ? (string)record["RegionDescription"] : default(string)); 
       }
	}

    public class SalesByCategoryAggregateRoot
	{
          public int CategoryId {get; set;}
          public string CategoryName {get; set;}
          public string ProductName {get; set;}
	}

    public static class SalesByCategory_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Sales by Category (CategoryID, CategoryName, ProductName, ProductSales) VALUES (@CategoryID, @CategoryName, @ProductName, @ProductSales)";
       public const string UpdateCmd = "UPDATE dbo.Sales by Category SET CategoryID = @CategoryId, CategoryName = @CategoryName, ProductName = @ProductName, ProductSales = @ProductSales WHERE CategoryID = @CategoryId AND CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string RemoveCmd = "DELETE FROM dbo.Sales by Category WHERE CategoryID = @CategoryId AND CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Sales by Category WHERE CategoryID = @CategoryId AND CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string FindCmd = "SELECT CategoryID, CategoryName, ProductName, ProductSales FROM dbo.Sales by Category WHERE CategoryID = @CategoryId AND CategoryName = @CategoryName AND ProductName = @ProductName";
	   public const string FindAllCmd = "SELECT CategoryID, CategoryName, ProductName, ProductSales FROM dbo.Sales by Category";

	   public static void Add(this IDbCommand command, SalesByCategory item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("ProductSales", item.ProductSales);
       }

	   public static void Update(this IDbCommand command, SalesByCategory item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
          command.AddParameter("ProductSales", item.ProductSales);
       }

	   public static void Remove(this IDbCommand command, SalesByCategory item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("CategoryId", item.CategoryId);
          command.AddParameter("CategoryName", item.CategoryName);
          command.AddParameter("ProductName", item.ProductName);
       }

	   public static void RemoveByKey_SalesByCategory(this IDbCommand command, SalesByCategoryAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("CategoryId", key.CategoryId);
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Find_SalesByCategory(this IDbCommand command, SalesByCategoryAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("CategoryId", key.CategoryId);
          command.AddParameter("CategoryName", key.CategoryName);
          command.AddParameter("ProductName", key.ProductName);
       }

	   public static void Map_SalesByCategory(this IDataRecord record, SalesByCategory entity)
       {
          entity.CategoryId = (!record.IsDBNull(0) ? (int)record["CategoryID"] : default(int)); 
          entity.CategoryName = (!record.IsDBNull(1) ? (string)record["CategoryName"] : default(string)); 
          entity.ProductName = (!record.IsDBNull(2) ? (string)record["ProductName"] : default(string)); 
          entity.ProductSales = (!record.IsDBNull(3) ? (decimal)record["ProductSales"] : default(decimal)); 
       }
	}

    public class SalesTotalsByAmountAggregateRoot
	{
          public int OrderId {get; set;}
          public string CompanyName {get; set;}
	}

    public static class SalesTotalsByAmount_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Sales Totals by Amount (SaleAmount, OrderID, CompanyName, ShippedDate) VALUES (@SaleAmount, @OrderID, @CompanyName, @ShippedDate)";
       public const string UpdateCmd = "UPDATE dbo.Sales Totals by Amount SET SaleAmount = @SaleAmount, OrderID = @OrderId, CompanyName = @CompanyName, ShippedDate = @ShippedDate WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string RemoveCmd = "DELETE FROM dbo.Sales Totals by Amount WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Sales Totals by Amount WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string FindCmd = "SELECT SaleAmount, OrderID, CompanyName, ShippedDate FROM dbo.Sales Totals by Amount WHERE OrderID = @OrderId AND CompanyName = @CompanyName";
	   public const string FindAllCmd = "SELECT SaleAmount, OrderID, CompanyName, ShippedDate FROM dbo.Sales Totals by Amount";

	   public static void Add(this IDbCommand command, SalesTotalsByAmount item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("SaleAmount", item.SaleAmount);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ShippedDate", item.ShippedDate);
       }

	   public static void Update(this IDbCommand command, SalesTotalsByAmount item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("SaleAmount", item.SaleAmount);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ShippedDate", item.ShippedDate);
       }

	   public static void Remove(this IDbCommand command, SalesTotalsByAmount item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("CompanyName", item.CompanyName);
       }

	   public static void RemoveByKey_SalesTotalsByAmount(this IDbCommand command, SalesTotalsByAmountAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("CompanyName", key.CompanyName);
       }

	   public static void Find_SalesTotalsByAmount(this IDbCommand command, SalesTotalsByAmountAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
          command.AddParameter("CompanyName", key.CompanyName);
       }

	   public static void Map_SalesTotalsByAmount(this IDataRecord record, SalesTotalsByAmount entity)
       {
          entity.SaleAmount = (!record.IsDBNull(0) ? (decimal)record["SaleAmount"] : default(decimal)); 
          entity.OrderId = (!record.IsDBNull(1) ? (int)record["OrderID"] : default(int)); 
          entity.CompanyName = (!record.IsDBNull(2) ? (string)record["CompanyName"] : default(string)); 
          entity.ShippedDate = (!record.IsDBNull(3) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
       }
	}

    public class ShipperAggregateRoot
	{
          public int ShipperId {get; set;}
	}

    public static class Shipper_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Shippers (CompanyName, Phone) VALUES (@CompanyName, @Phone)";
       public const string UpdateCmd = "UPDATE dbo.Shippers SET CompanyName = @CompanyName, Phone = @Phone WHERE ShipperID = @ShipperId";
	   public const string RemoveCmd = "DELETE FROM dbo.Shippers WHERE ShipperID = @ShipperId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Shippers WHERE ShipperID = @ShipperId";
	   public const string FindCmd = "SELECT CompanyName, Phone FROM dbo.Shippers WHERE ShipperID = @ShipperId";
	   public const string FindAllCmd = "SELECT CompanyName, Phone FROM dbo.Shippers";

	   public static void Add(this IDbCommand command, Shipper item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("Phone", item.Phone);
       }

	   public static void Update(this IDbCommand command, Shipper item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("Phone", item.Phone);
       }

	   public static void Remove(this IDbCommand command, Shipper item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("ShipperId", item.ShipperId);
       }

	   public static void RemoveByKey_Shipper(this IDbCommand command, ShipperAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("ShipperId", key.ShipperId);
       }

	   public static void Find_Shipper(this IDbCommand command, ShipperAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("ShipperId", key.ShipperId);
       }

	   public static void Map_Shipper(this IDataRecord record, Shipper entity)
       {
          entity.ShipperId = (!record.IsDBNull(0) ? (int)record["ShipperID"] : default(int)); 
          entity.CompanyName = (!record.IsDBNull(1) ? (string)record["CompanyName"] : default(string)); 
          entity.Phone = (!record.IsDBNull(2) ? (string)record["Phone"] : default(string)); 
       }
	}

    public class SummaryOfSalesByQuarterAggregateRoot
	{
          public int OrderId {get; set;}
	}

    public static class SummaryOfSalesByQuarter_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Summary of Sales by Quarter (ShippedDate, OrderID, Subtotal) VALUES (@ShippedDate, @OrderID, @Subtotal)";
       public const string UpdateCmd = "UPDATE dbo.Summary of Sales by Quarter SET ShippedDate = @ShippedDate, OrderID = @OrderId, Subtotal = @Subtotal WHERE OrderID = @OrderId";
	   public const string RemoveCmd = "DELETE FROM dbo.Summary of Sales by Quarter WHERE OrderID = @OrderId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Summary of Sales by Quarter WHERE OrderID = @OrderId";
	   public const string FindCmd = "SELECT ShippedDate, OrderID, Subtotal FROM dbo.Summary of Sales by Quarter WHERE OrderID = @OrderId";
	   public const string FindAllCmd = "SELECT ShippedDate, OrderID, Subtotal FROM dbo.Summary of Sales by Quarter";

	   public static void Add(this IDbCommand command, SummaryOfSalesByQuarter item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Update(this IDbCommand command, SummaryOfSalesByQuarter item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Remove(this IDbCommand command, SummaryOfSalesByQuarter item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
       }

	   public static void RemoveByKey_SummaryOfSalesByQuarter(this IDbCommand command, SummaryOfSalesByQuarterAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Find_SummaryOfSalesByQuarter(this IDbCommand command, SummaryOfSalesByQuarterAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Map_SummaryOfSalesByQuarter(this IDataRecord record, SummaryOfSalesByQuarter entity)
       {
          entity.ShippedDate = (!record.IsDBNull(0) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
          entity.OrderId = (!record.IsDBNull(1) ? (int)record["OrderID"] : default(int)); 
          entity.Subtotal = (!record.IsDBNull(2) ? (decimal)record["Subtotal"] : default(decimal)); 
       }
	}

    public class SummaryOfSalesByYearAggregateRoot
	{
          public int OrderId {get; set;}
	}

    public static class SummaryOfSalesByYear_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Summary of Sales by Year (ShippedDate, OrderID, Subtotal) VALUES (@ShippedDate, @OrderID, @Subtotal)";
       public const string UpdateCmd = "UPDATE dbo.Summary of Sales by Year SET ShippedDate = @ShippedDate, OrderID = @OrderId, Subtotal = @Subtotal WHERE OrderID = @OrderId";
	   public const string RemoveCmd = "DELETE FROM dbo.Summary of Sales by Year WHERE OrderID = @OrderId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Summary of Sales by Year WHERE OrderID = @OrderId";
	   public const string FindCmd = "SELECT ShippedDate, OrderID, Subtotal FROM dbo.Summary of Sales by Year WHERE OrderID = @OrderId";
	   public const string FindAllCmd = "SELECT ShippedDate, OrderID, Subtotal FROM dbo.Summary of Sales by Year";

	   public static void Add(this IDbCommand command, SummaryOfSalesByYear item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Update(this IDbCommand command, SummaryOfSalesByYear item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("ShippedDate", item.ShippedDate);
          command.AddParameter("OrderId", item.OrderId);
          command.AddParameter("Subtotal", item.Subtotal);
       }

	   public static void Remove(this IDbCommand command, SummaryOfSalesByYear item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("OrderId", item.OrderId);
       }

	   public static void RemoveByKey_SummaryOfSalesByYear(this IDbCommand command, SummaryOfSalesByYearAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Find_SummaryOfSalesByYear(this IDbCommand command, SummaryOfSalesByYearAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("OrderId", key.OrderId);
       }

	   public static void Map_SummaryOfSalesByYear(this IDataRecord record, SummaryOfSalesByYear entity)
       {
          entity.ShippedDate = (!record.IsDBNull(0) ? (System.DateTime)record["ShippedDate"] : default(System.DateTime)); 
          entity.OrderId = (!record.IsDBNull(1) ? (int)record["OrderID"] : default(int)); 
          entity.Subtotal = (!record.IsDBNull(2) ? (decimal)record["Subtotal"] : default(decimal)); 
       }
	}

    public class SupplierAggregateRoot
	{
          public int SupplierId {get; set;}
	}

    public static class Supplier_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Suppliers (CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage) VALUES (@CompanyName, @ContactName, @ContactTitle, @Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax, @HomePage)";
       public const string UpdateCmd = "UPDATE dbo.Suppliers SET CompanyName = @CompanyName, ContactName = @ContactName, ContactTitle = @ContactTitle, Address = @Address, City = @City, Region = @Region, PostalCode = @PostalCode, Country = @Country, Phone = @Phone, Fax = @Fax, HomePage = @HomePage WHERE SupplierID = @SupplierId";
	   public const string RemoveCmd = "DELETE FROM dbo.Suppliers WHERE SupplierID = @SupplierId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Suppliers WHERE SupplierID = @SupplierId";
	   public const string FindCmd = "SELECT CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage FROM dbo.Suppliers WHERE SupplierID = @SupplierId";
	   public const string FindAllCmd = "SELECT CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage FROM dbo.Suppliers";

	   public static void Add(this IDbCommand command, Supplier item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("ContactTitle", item.ContactTitle);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Phone", item.Phone);
          command.AddParameter("Fax", item.Fax);
          command.AddParameter("HomePage", item.HomePage);
       }

	   public static void Update(this IDbCommand command, Supplier item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("CompanyName", item.CompanyName);
          command.AddParameter("ContactName", item.ContactName);
          command.AddParameter("ContactTitle", item.ContactTitle);
          command.AddParameter("Address", item.Address);
          command.AddParameter("City", item.City);
          command.AddParameter("Region", item.Region);
          command.AddParameter("PostalCode", item.PostalCode);
          command.AddParameter("Country", item.Country);
          command.AddParameter("Phone", item.Phone);
          command.AddParameter("Fax", item.Fax);
          command.AddParameter("HomePage", item.HomePage);
       }

	   public static void Remove(this IDbCommand command, Supplier item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("SupplierId", item.SupplierId);
       }

	   public static void RemoveByKey_Supplier(this IDbCommand command, SupplierAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("SupplierId", key.SupplierId);
       }

	   public static void Find_Supplier(this IDbCommand command, SupplierAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("SupplierId", key.SupplierId);
       }

	   public static void Map_Supplier(this IDataRecord record, Supplier entity)
       {
          entity.SupplierId = (!record.IsDBNull(0) ? (int)record["SupplierID"] : default(int)); 
          entity.CompanyName = (!record.IsDBNull(1) ? (string)record["CompanyName"] : default(string)); 
          entity.ContactName = (!record.IsDBNull(2) ? (string)record["ContactName"] : default(string)); 
          entity.ContactTitle = (!record.IsDBNull(3) ? (string)record["ContactTitle"] : default(string)); 
          entity.Address = (!record.IsDBNull(4) ? (string)record["Address"] : default(string)); 
          entity.City = (!record.IsDBNull(5) ? (string)record["City"] : default(string)); 
          entity.Region = (!record.IsDBNull(6) ? (string)record["Region"] : default(string)); 
          entity.PostalCode = (!record.IsDBNull(7) ? (string)record["PostalCode"] : default(string)); 
          entity.Country = (!record.IsDBNull(8) ? (string)record["Country"] : default(string)); 
          entity.Phone = (!record.IsDBNull(9) ? (string)record["Phone"] : default(string)); 
          entity.Fax = (!record.IsDBNull(10) ? (string)record["Fax"] : default(string)); 
          entity.HomePage = (!record.IsDBNull(11) ? (string)record["HomePage"] : default(string)); 
       }
	}

    public class TerritoryAggregateRoot
	{
          public string TerritoryId {get; set;}
	}

    public static class Territory_Util
    {
     
       public const string InsertCmd = "INSERT INTO dbo.Territories (TerritoryID, TerritoryDescription, RegionID) VALUES (@TerritoryID, @TerritoryDescription, @RegionID)";
       public const string UpdateCmd = "UPDATE dbo.Territories SET TerritoryID = @TerritoryId, TerritoryDescription = @TerritoryDescription, RegionID = @RegionId WHERE TerritoryID = @TerritoryId";
	   public const string RemoveCmd = "DELETE FROM dbo.Territories WHERE TerritoryID = @TerritoryId";
	   public const string RemoveCmdByKey = "DELETE FROM dbo.Territories WHERE TerritoryID = @TerritoryId";
	   public const string FindCmd = "SELECT TerritoryID, TerritoryDescription, RegionID FROM dbo.Territories WHERE TerritoryID = @TerritoryId";
	   public const string FindAllCmd = "SELECT TerritoryID, TerritoryDescription, RegionID FROM dbo.Territories";

	   public static void Add(this IDbCommand command, Territory item)
       {
	      command.CommandText = InsertCmd;
          command.AddParameter("TerritoryId", item.TerritoryId);
          command.AddParameter("TerritoryDescription", item.TerritoryDescription);
          command.AddParameter("RegionId", item.RegionId);
       }

	   public static void Update(this IDbCommand command, Territory item)
       {
	      command.CommandText = UpdateCmd;
          command.AddParameter("TerritoryId", item.TerritoryId);
          command.AddParameter("TerritoryDescription", item.TerritoryDescription);
          command.AddParameter("RegionId", item.RegionId);
       }

	   public static void Remove(this IDbCommand command, Territory item)
       {
	      command.CommandText = RemoveCmd;
          command.AddParameter("TerritoryId", item.TerritoryId);
       }

	   public static void RemoveByKey_Territory(this IDbCommand command, TerritoryAggregateRoot key)
       {
	      command.CommandText = RemoveCmdByKey;
          command.AddParameter("TerritoryId", key.TerritoryId);
       }

	   public static void Find_Territory(this IDbCommand command, TerritoryAggregateRoot key)
       {
	      command.CommandText = FindCmd;
          command.AddParameter("TerritoryId", key.TerritoryId);
       }

	   public static void Map_Territory(this IDataRecord record, Territory entity)
       {
          entity.TerritoryId = (!record.IsDBNull(0) ? (string)record["TerritoryID"] : default(string)); 
          entity.TerritoryDescription = (!record.IsDBNull(1) ? (string)record["TerritoryDescription"] : default(string)); 
          entity.RegionId = (!record.IsDBNull(2) ? (int)record["RegionID"] : default(int)); 
       }
	}

}

// ************************************************************************
// Repositories classes for ADO.NET Extension...
// ************************************************************************
namespace DAL.ADO.Repositories
{
    using System;
    using System.Data;
    using GrayParrot.Core.Data;
    using GrayParrot.Data.ADONET;
    using System.Collections.Generic;
	using DAL.ADO.Utilities;
    public class AlphabeticalListOfProductRepository : Repository<AlphabeticalListOfProduct, AlphabeticalListOfProductAggregateRoot>
    {
	    private DbContext m_context = null;

		public AlphabeticalListOfProductRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(AlphabeticalListOfProduct item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "AlphabeticalListOfProductRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(AlphabeticalListOfProduct item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(AlphabeticalListOfProduct item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(AlphabeticalListOfProductAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_AlphabeticalListOfProduct(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<AlphabeticalListOfProduct> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = AlphabeticalListOfProduct_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override AlphabeticalListOfProduct Find(AlphabeticalListOfProductAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_AlphabeticalListOfProduct(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<AlphabeticalListOfProduct> Find(System.Linq.Expressions.Expression<Func<AlphabeticalListOfProduct, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, AlphabeticalListOfProduct entity)
        {
            record.Map_AlphabeticalListOfProduct(entity);
        }
	}

    public class CategoryRepository : Repository<Category, CategoryAggregateRoot>
    {
	    private DbContext m_context = null;

		public CategoryRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Category item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CategoryRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Category item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Category item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Category(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Category> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Category_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Category Find(CategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Category(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Category> Find(System.Linq.Expressions.Expression<Func<Category, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Category entity)
        {
            record.Map_Category(entity);
        }
	}

    public class CategorySalesFor1997Repository : Repository<CategorySalesFor1997, CategorySalesFor1997AggregateRoot>
    {
	    private DbContext m_context = null;

		public CategorySalesFor1997Repository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(CategorySalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CategorySalesFor1997Repository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(CategorySalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CategorySalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CategorySalesFor1997AggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_CategorySalesFor1997(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<CategorySalesFor1997> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = CategorySalesFor1997_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override CategorySalesFor1997 Find(CategorySalesFor1997AggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_CategorySalesFor1997(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<CategorySalesFor1997> Find(System.Linq.Expressions.Expression<Func<CategorySalesFor1997, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, CategorySalesFor1997 entity)
        {
            record.Map_CategorySalesFor1997(entity);
        }
	}

    public class CurrentProductListRepository : Repository<CurrentProductList, CurrentProductListAggregateRoot>
    {
	    private DbContext m_context = null;

		public CurrentProductListRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(CurrentProductList item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CurrentProductListRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(CurrentProductList item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CurrentProductList item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CurrentProductListAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_CurrentProductList(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<CurrentProductList> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = CurrentProductList_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override CurrentProductList Find(CurrentProductListAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_CurrentProductList(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<CurrentProductList> Find(System.Linq.Expressions.Expression<Func<CurrentProductList, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, CurrentProductList entity)
        {
            record.Map_CurrentProductList(entity);
        }
	}

    public class CustomerRepository : Repository<Customer, CustomerAggregateRoot>
    {
	    private DbContext m_context = null;

		public CustomerRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Customer item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CustomerRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Customer item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Customer item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CustomerAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Customer(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Customer> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Customer_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Customer Find(CustomerAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Customer(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Customer> Find(System.Linq.Expressions.Expression<Func<Customer, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Customer entity)
        {
            record.Map_Customer(entity);
        }
	}

    public class CustomerAndSuppliersByCityRepository : Repository<CustomerAndSuppliersByCity, CustomerAndSuppliersByCityAggregateRoot>
    {
	    private DbContext m_context = null;

		public CustomerAndSuppliersByCityRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(CustomerAndSuppliersByCity item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CustomerAndSuppliersByCityRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(CustomerAndSuppliersByCity item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CustomerAndSuppliersByCity item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CustomerAndSuppliersByCityAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_CustomerAndSuppliersByCity(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<CustomerAndSuppliersByCity> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = CustomerAndSuppliersByCity_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override CustomerAndSuppliersByCity Find(CustomerAndSuppliersByCityAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_CustomerAndSuppliersByCity(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<CustomerAndSuppliersByCity> Find(System.Linq.Expressions.Expression<Func<CustomerAndSuppliersByCity, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, CustomerAndSuppliersByCity entity)
        {
            record.Map_CustomerAndSuppliersByCity(entity);
        }
	}

    public class CustomerDemographicRepository : Repository<CustomerDemographic, CustomerDemographicAggregateRoot>
    {
	    private DbContext m_context = null;

		public CustomerDemographicRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(CustomerDemographic item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "CustomerDemographicRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(CustomerDemographic item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CustomerDemographic item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(CustomerDemographicAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_CustomerDemographic(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<CustomerDemographic> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = CustomerDemographic_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override CustomerDemographic Find(CustomerDemographicAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_CustomerDemographic(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<CustomerDemographic> Find(System.Linq.Expressions.Expression<Func<CustomerDemographic, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, CustomerDemographic entity)
        {
            record.Map_CustomerDemographic(entity);
        }
	}

    public class EmployeeRepository : Repository<Employee, EmployeeAggregateRoot>
    {
	    private DbContext m_context = null;

		public EmployeeRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Employee item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "EmployeeRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Employee item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Employee item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(EmployeeAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Employee(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Employee> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Employee_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Employee Find(EmployeeAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Employee(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Employee> Find(System.Linq.Expressions.Expression<Func<Employee, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Employee entity)
        {
            record.Map_Employee(entity);
        }
	}

    public class InvoiceRepository : Repository<Invoice, InvoiceAggregateRoot>
    {
	    private DbContext m_context = null;

		public InvoiceRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Invoice item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "InvoiceRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Invoice item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Invoice item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(InvoiceAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Invoice(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Invoice> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Invoice_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Invoice Find(InvoiceAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Invoice(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Invoice> Find(System.Linq.Expressions.Expression<Func<Invoice, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Invoice entity)
        {
            record.Map_Invoice(entity);
        }
	}

    public class OrderRepository : Repository<Order, OrderAggregateRoot>
    {
	    private DbContext m_context = null;

		public OrderRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Order item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "OrderRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Order item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Order item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Order(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Order> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Order_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Order Find(OrderAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Order(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Order> Find(System.Linq.Expressions.Expression<Func<Order, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Order entity)
        {
            record.Map_Order(entity);
        }
	}

    public class OrderDetailRepository : Repository<OrderDetail, OrderDetailAggregateRoot>
    {
	    private DbContext m_context = null;

		public OrderDetailRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(OrderDetail item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "OrderDetailRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(OrderDetail item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderDetail item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderDetailAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_OrderDetail(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<OrderDetail> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = OrderDetail_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override OrderDetail Find(OrderDetailAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_OrderDetail(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<OrderDetail> Find(System.Linq.Expressions.Expression<Func<OrderDetail, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, OrderDetail entity)
        {
            record.Map_OrderDetail(entity);
        }
	}

    public class OrderDetailsExtendedRepository : Repository<OrderDetailsExtended, OrderDetailsExtendedAggregateRoot>
    {
	    private DbContext m_context = null;

		public OrderDetailsExtendedRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(OrderDetailsExtended item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "OrderDetailsExtendedRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(OrderDetailsExtended item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderDetailsExtended item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderDetailsExtendedAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_OrderDetailsExtended(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<OrderDetailsExtended> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = OrderDetailsExtended_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override OrderDetailsExtended Find(OrderDetailsExtendedAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_OrderDetailsExtended(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<OrderDetailsExtended> Find(System.Linq.Expressions.Expression<Func<OrderDetailsExtended, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, OrderDetailsExtended entity)
        {
            record.Map_OrderDetailsExtended(entity);
        }
	}

    public class OrdersQryRepository : Repository<OrdersQry, OrdersQryAggregateRoot>
    {
	    private DbContext m_context = null;

		public OrdersQryRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(OrdersQry item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "OrdersQryRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(OrdersQry item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrdersQry item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrdersQryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_OrdersQry(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<OrdersQry> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = OrdersQry_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override OrdersQry Find(OrdersQryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_OrdersQry(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<OrdersQry> Find(System.Linq.Expressions.Expression<Func<OrdersQry, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, OrdersQry entity)
        {
            record.Map_OrdersQry(entity);
        }
	}

    public class OrderSubtotalRepository : Repository<OrderSubtotal, OrderSubtotalAggregateRoot>
    {
	    private DbContext m_context = null;

		public OrderSubtotalRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(OrderSubtotal item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "OrderSubtotalRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(OrderSubtotal item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderSubtotal item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(OrderSubtotalAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_OrderSubtotal(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<OrderSubtotal> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = OrderSubtotal_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override OrderSubtotal Find(OrderSubtotalAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_OrderSubtotal(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<OrderSubtotal> Find(System.Linq.Expressions.Expression<Func<OrderSubtotal, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, OrderSubtotal entity)
        {
            record.Map_OrderSubtotal(entity);
        }
	}

    public class ProductRepository : Repository<Product, ProductAggregateRoot>
    {
	    private DbContext m_context = null;

		public ProductRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Product item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "ProductRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Product item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Product item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Product(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Product> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Product_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Product Find(ProductAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Product(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Product> Find(System.Linq.Expressions.Expression<Func<Product, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Product entity)
        {
            record.Map_Product(entity);
        }
	}

    public class ProductsAboveAveragePriceRepository : Repository<ProductsAboveAveragePrice, ProductsAboveAveragePriceAggregateRoot>
    {
	    private DbContext m_context = null;

		public ProductsAboveAveragePriceRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(ProductsAboveAveragePrice item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "ProductsAboveAveragePriceRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(ProductsAboveAveragePrice item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductsAboveAveragePrice item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductsAboveAveragePriceAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_ProductsAboveAveragePrice(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<ProductsAboveAveragePrice> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = ProductsAboveAveragePrice_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override ProductsAboveAveragePrice Find(ProductsAboveAveragePriceAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_ProductsAboveAveragePrice(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<ProductsAboveAveragePrice> Find(System.Linq.Expressions.Expression<Func<ProductsAboveAveragePrice, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, ProductsAboveAveragePrice entity)
        {
            record.Map_ProductsAboveAveragePrice(entity);
        }
	}

    public class ProductSalesFor1997Repository : Repository<ProductSalesFor1997, ProductSalesFor1997AggregateRoot>
    {
	    private DbContext m_context = null;

		public ProductSalesFor1997Repository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(ProductSalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "ProductSalesFor1997Repository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(ProductSalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductSalesFor1997 item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductSalesFor1997AggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_ProductSalesFor1997(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<ProductSalesFor1997> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = ProductSalesFor1997_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override ProductSalesFor1997 Find(ProductSalesFor1997AggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_ProductSalesFor1997(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<ProductSalesFor1997> Find(System.Linq.Expressions.Expression<Func<ProductSalesFor1997, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, ProductSalesFor1997 entity)
        {
            record.Map_ProductSalesFor1997(entity);
        }
	}

    public class ProductsByCategoryRepository : Repository<ProductsByCategory, ProductsByCategoryAggregateRoot>
    {
	    private DbContext m_context = null;

		public ProductsByCategoryRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(ProductsByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "ProductsByCategoryRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(ProductsByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductsByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ProductsByCategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_ProductsByCategory(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<ProductsByCategory> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = ProductsByCategory_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override ProductsByCategory Find(ProductsByCategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_ProductsByCategory(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<ProductsByCategory> Find(System.Linq.Expressions.Expression<Func<ProductsByCategory, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, ProductsByCategory entity)
        {
            record.Map_ProductsByCategory(entity);
        }
	}

    public class QuarterlyOrderRepository : Repository<QuarterlyOrder, QuarterlyOrderAggregateRoot>
    {
	    private DbContext m_context = null;

		public QuarterlyOrderRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(QuarterlyOrder item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "QuarterlyOrderRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(QuarterlyOrder item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(QuarterlyOrder item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(QuarterlyOrderAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_QuarterlyOrder(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<QuarterlyOrder> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = QuarterlyOrder_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override QuarterlyOrder Find(QuarterlyOrderAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_QuarterlyOrder(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<QuarterlyOrder> Find(System.Linq.Expressions.Expression<Func<QuarterlyOrder, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, QuarterlyOrder entity)
        {
            record.Map_QuarterlyOrder(entity);
        }
	}

    public class RegionRepository : Repository<Region, RegionAggregateRoot>
    {
	    private DbContext m_context = null;

		public RegionRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Region item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "RegionRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Region item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Region item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(RegionAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Region(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Region> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Region_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Region Find(RegionAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Region(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Region> Find(System.Linq.Expressions.Expression<Func<Region, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Region entity)
        {
            record.Map_Region(entity);
        }
	}

    public class SalesByCategoryRepository : Repository<SalesByCategory, SalesByCategoryAggregateRoot>
    {
	    private DbContext m_context = null;

		public SalesByCategoryRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(SalesByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "SalesByCategoryRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(SalesByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SalesByCategory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SalesByCategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_SalesByCategory(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<SalesByCategory> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = SalesByCategory_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override SalesByCategory Find(SalesByCategoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_SalesByCategory(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<SalesByCategory> Find(System.Linq.Expressions.Expression<Func<SalesByCategory, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, SalesByCategory entity)
        {
            record.Map_SalesByCategory(entity);
        }
	}

    public class SalesTotalsByAmountRepository : Repository<SalesTotalsByAmount, SalesTotalsByAmountAggregateRoot>
    {
	    private DbContext m_context = null;

		public SalesTotalsByAmountRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(SalesTotalsByAmount item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "SalesTotalsByAmountRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(SalesTotalsByAmount item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SalesTotalsByAmount item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SalesTotalsByAmountAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_SalesTotalsByAmount(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<SalesTotalsByAmount> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = SalesTotalsByAmount_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override SalesTotalsByAmount Find(SalesTotalsByAmountAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_SalesTotalsByAmount(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<SalesTotalsByAmount> Find(System.Linq.Expressions.Expression<Func<SalesTotalsByAmount, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, SalesTotalsByAmount entity)
        {
            record.Map_SalesTotalsByAmount(entity);
        }
	}

    public class ShipperRepository : Repository<Shipper, ShipperAggregateRoot>
    {
	    private DbContext m_context = null;

		public ShipperRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Shipper item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "ShipperRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Shipper item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Shipper item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(ShipperAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Shipper(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Shipper> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Shipper_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Shipper Find(ShipperAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Shipper(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Shipper> Find(System.Linq.Expressions.Expression<Func<Shipper, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Shipper entity)
        {
            record.Map_Shipper(entity);
        }
	}

    public class SummaryOfSalesByQuarterRepository : Repository<SummaryOfSalesByQuarter, SummaryOfSalesByQuarterAggregateRoot>
    {
	    private DbContext m_context = null;

		public SummaryOfSalesByQuarterRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(SummaryOfSalesByQuarter item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "SummaryOfSalesByQuarterRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(SummaryOfSalesByQuarter item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SummaryOfSalesByQuarter item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SummaryOfSalesByQuarterAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_SummaryOfSalesByQuarter(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<SummaryOfSalesByQuarter> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = SummaryOfSalesByQuarter_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override SummaryOfSalesByQuarter Find(SummaryOfSalesByQuarterAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_SummaryOfSalesByQuarter(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<SummaryOfSalesByQuarter> Find(System.Linq.Expressions.Expression<Func<SummaryOfSalesByQuarter, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, SummaryOfSalesByQuarter entity)
        {
            record.Map_SummaryOfSalesByQuarter(entity);
        }
	}

    public class SummaryOfSalesByYearRepository : Repository<SummaryOfSalesByYear, SummaryOfSalesByYearAggregateRoot>
    {
	    private DbContext m_context = null;

		public SummaryOfSalesByYearRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(SummaryOfSalesByYear item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "SummaryOfSalesByYearRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(SummaryOfSalesByYear item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SummaryOfSalesByYear item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SummaryOfSalesByYearAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_SummaryOfSalesByYear(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<SummaryOfSalesByYear> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = SummaryOfSalesByYear_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override SummaryOfSalesByYear Find(SummaryOfSalesByYearAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_SummaryOfSalesByYear(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<SummaryOfSalesByYear> Find(System.Linq.Expressions.Expression<Func<SummaryOfSalesByYear, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, SummaryOfSalesByYear entity)
        {
            record.Map_SummaryOfSalesByYear(entity);
        }
	}

    public class SupplierRepository : Repository<Supplier, SupplierAggregateRoot>
    {
	    private DbContext m_context = null;

		public SupplierRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Supplier item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "SupplierRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Supplier item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Supplier item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(SupplierAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Supplier(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Supplier> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Supplier_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Supplier Find(SupplierAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Supplier(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Supplier> Find(System.Linq.Expressions.Expression<Func<Supplier, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Supplier entity)
        {
            record.Map_Supplier(entity);
        }
	}

    public class TerritoryRepository : Repository<Territory, TerritoryAggregateRoot>
    {
	    private DbContext m_context = null;

		public TerritoryRepository(DbContext context) : base(context)
        {
		    m_context = context;
        }

        public override void Add(Territory item)
        {
		    if(!this.Context.HasValidConnection) return;

		    try
			{
				using (var command = this.Context.CreateCommand())
				{
					command.Add(item);
					command.ExecuteNonQuery();
				}
			}
			catch(Exception ex)
			{
			    ex.Data["MName"] = "TerritoryRepository.Add";
			    m_context.ErrorHandler(ex);
			    //throw new Exception(ex0.Message, ex0);
			}
            //todo: Get identity. Depends on the db engine.
        }

        public override void Update(Territory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Update(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(Territory item)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.Remove(item);
                command.ExecuteNonQuery();
            }
        }

        public override void Remove(TerritoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return;
            using (var command = this.Context.CreateCommand())
            {
                command.RemoveByKey_Territory(key);
                command.ExecuteNonQuery();
            }
        }

        public override IEnumerable<Territory> FindAll()
        {   
            if(!this.Context.HasValidConnection) return null;        
			using (var command = this.Context.CreateCommand())
            {
                command.CommandText = Territory_Util.FindAllCmd;
                return ToList(command);
            }
        }

        public override Territory Find(TerritoryAggregateRoot key)
        {
		    if(!this.Context.HasValidConnection) return null;
            using (var command = this.Context.CreateCommand())
            {
                command.Find_Territory(key);
                return ToEntity(command);
            }
        }

        public override IEnumerable<Territory> Find(System.Linq.Expressions.Expression<Func<Territory, bool>> predicate)
        {
		    if(!this.Context.HasValidConnection) return null;
            
			var translator = new QueryTranslator();
            string whereClause = translator.Translate(predicate);

            using (var command = this.Context.CreateCommand())
            {
                command.CommandText = "SELECT * FROM dbo.Customers WHERE " + whereClause;
                return ToList(command);
            }
        }

        protected override void Map(IDataRecord record, Territory entity)
        {
            record.Map_Territory(entity);
        }
	}

}

// ************************************************************************
// Facades classes for ADO.NET Extension...
// ************************************************************************
namespace DAL.ADO.Facades
{
    using GrayParrot.Core.Data;
	using GrayParrot.Data.ADONET;
	using DAL.ADO.Repositories;

    public interface IFacadeBase
    {
        void Initialize();
        void Dispose();
    }

    public partial class AlphabeticalListOfProductFacade : GrayParrot.Data.ADONET.FacadeBase<AlphabeticalListOfProductFacade>
    {
	    private AlphabeticalListOfProductRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public AlphabeticalListOfProductRepository Repository { get { return m_repository; } }

        public AlphabeticalListOfProductFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new AlphabeticalListOfProductRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new AlphabeticalListOfProductRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CategoryFacade : GrayParrot.Data.ADONET.FacadeBase<CategoryFacade>
    {
	    private CategoryRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CategoryRepository Repository { get { return m_repository; } }

        public CategoryFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CategoryRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CategoryRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CategorySalesFor1997Facade : GrayParrot.Data.ADONET.FacadeBase<CategorySalesFor1997Facade>
    {
	    private CategorySalesFor1997Repository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CategorySalesFor1997Repository Repository { get { return m_repository; } }

        public CategorySalesFor1997Facade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CategorySalesFor1997Repository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CategorySalesFor1997Repository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CurrentProductListFacade : GrayParrot.Data.ADONET.FacadeBase<CurrentProductListFacade>
    {
	    private CurrentProductListRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CurrentProductListRepository Repository { get { return m_repository; } }

        public CurrentProductListFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CurrentProductListRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CurrentProductListRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CustomerFacade : GrayParrot.Data.ADONET.FacadeBase<CustomerFacade>
    {
	    private CustomerRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CustomerRepository Repository { get { return m_repository; } }

        public CustomerFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CustomerRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CustomerRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CustomerAndSuppliersByCityFacade : GrayParrot.Data.ADONET.FacadeBase<CustomerAndSuppliersByCityFacade>
    {
	    private CustomerAndSuppliersByCityRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CustomerAndSuppliersByCityRepository Repository { get { return m_repository; } }

        public CustomerAndSuppliersByCityFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CustomerAndSuppliersByCityRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CustomerAndSuppliersByCityRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class CustomerDemographicFacade : GrayParrot.Data.ADONET.FacadeBase<CustomerDemographicFacade>
    {
	    private CustomerDemographicRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public CustomerDemographicRepository Repository { get { return m_repository; } }

        public CustomerDemographicFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new CustomerDemographicRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new CustomerDemographicRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class EmployeeFacade : GrayParrot.Data.ADONET.FacadeBase<EmployeeFacade>
    {
	    private EmployeeRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public EmployeeRepository Repository { get { return m_repository; } }

        public EmployeeFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new EmployeeRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new EmployeeRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class InvoiceFacade : GrayParrot.Data.ADONET.FacadeBase<InvoiceFacade>
    {
	    private InvoiceRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public InvoiceRepository Repository { get { return m_repository; } }

        public InvoiceFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new InvoiceRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new InvoiceRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class OrderFacade : GrayParrot.Data.ADONET.FacadeBase<OrderFacade>
    {
	    private OrderRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public OrderRepository Repository { get { return m_repository; } }

        public OrderFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new OrderRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new OrderRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class OrderDetailFacade : GrayParrot.Data.ADONET.FacadeBase<OrderDetailFacade>
    {
	    private OrderDetailRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public OrderDetailRepository Repository { get { return m_repository; } }

        public OrderDetailFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new OrderDetailRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new OrderDetailRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class OrderDetailsExtendedFacade : GrayParrot.Data.ADONET.FacadeBase<OrderDetailsExtendedFacade>
    {
	    private OrderDetailsExtendedRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public OrderDetailsExtendedRepository Repository { get { return m_repository; } }

        public OrderDetailsExtendedFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new OrderDetailsExtendedRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new OrderDetailsExtendedRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class OrdersQryFacade : GrayParrot.Data.ADONET.FacadeBase<OrdersQryFacade>
    {
	    private OrdersQryRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public OrdersQryRepository Repository { get { return m_repository; } }

        public OrdersQryFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new OrdersQryRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new OrdersQryRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class OrderSubtotalFacade : GrayParrot.Data.ADONET.FacadeBase<OrderSubtotalFacade>
    {
	    private OrderSubtotalRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public OrderSubtotalRepository Repository { get { return m_repository; } }

        public OrderSubtotalFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new OrderSubtotalRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new OrderSubtotalRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class ProductFacade : GrayParrot.Data.ADONET.FacadeBase<ProductFacade>
    {
	    private ProductRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public ProductRepository Repository { get { return m_repository; } }

        public ProductFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new ProductRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new ProductRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class ProductsAboveAveragePriceFacade : GrayParrot.Data.ADONET.FacadeBase<ProductsAboveAveragePriceFacade>
    {
	    private ProductsAboveAveragePriceRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public ProductsAboveAveragePriceRepository Repository { get { return m_repository; } }

        public ProductsAboveAveragePriceFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new ProductsAboveAveragePriceRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new ProductsAboveAveragePriceRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class ProductSalesFor1997Facade : GrayParrot.Data.ADONET.FacadeBase<ProductSalesFor1997Facade>
    {
	    private ProductSalesFor1997Repository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public ProductSalesFor1997Repository Repository { get { return m_repository; } }

        public ProductSalesFor1997Facade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new ProductSalesFor1997Repository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new ProductSalesFor1997Repository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class ProductsByCategoryFacade : GrayParrot.Data.ADONET.FacadeBase<ProductsByCategoryFacade>
    {
	    private ProductsByCategoryRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public ProductsByCategoryRepository Repository { get { return m_repository; } }

        public ProductsByCategoryFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new ProductsByCategoryRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new ProductsByCategoryRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class QuarterlyOrderFacade : GrayParrot.Data.ADONET.FacadeBase<QuarterlyOrderFacade>
    {
	    private QuarterlyOrderRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public QuarterlyOrderRepository Repository { get { return m_repository; } }

        public QuarterlyOrderFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new QuarterlyOrderRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new QuarterlyOrderRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class RegionFacade : GrayParrot.Data.ADONET.FacadeBase<RegionFacade>
    {
	    private RegionRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public RegionRepository Repository { get { return m_repository; } }

        public RegionFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new RegionRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new RegionRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class SalesByCategoryFacade : GrayParrot.Data.ADONET.FacadeBase<SalesByCategoryFacade>
    {
	    private SalesByCategoryRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public SalesByCategoryRepository Repository { get { return m_repository; } }

        public SalesByCategoryFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new SalesByCategoryRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new SalesByCategoryRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class SalesTotalsByAmountFacade : GrayParrot.Data.ADONET.FacadeBase<SalesTotalsByAmountFacade>
    {
	    private SalesTotalsByAmountRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public SalesTotalsByAmountRepository Repository { get { return m_repository; } }

        public SalesTotalsByAmountFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new SalesTotalsByAmountRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new SalesTotalsByAmountRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class ShipperFacade : GrayParrot.Data.ADONET.FacadeBase<ShipperFacade>
    {
	    private ShipperRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public ShipperRepository Repository { get { return m_repository; } }

        public ShipperFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new ShipperRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new ShipperRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class SummaryOfSalesByQuarterFacade : GrayParrot.Data.ADONET.FacadeBase<SummaryOfSalesByQuarterFacade>
    {
	    private SummaryOfSalesByQuarterRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public SummaryOfSalesByQuarterRepository Repository { get { return m_repository; } }

        public SummaryOfSalesByQuarterFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new SummaryOfSalesByQuarterRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new SummaryOfSalesByQuarterRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class SummaryOfSalesByYearFacade : GrayParrot.Data.ADONET.FacadeBase<SummaryOfSalesByYearFacade>
    {
	    private SummaryOfSalesByYearRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public SummaryOfSalesByYearRepository Repository { get { return m_repository; } }

        public SummaryOfSalesByYearFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new SummaryOfSalesByYearRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new SummaryOfSalesByYearRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class SupplierFacade : GrayParrot.Data.ADONET.FacadeBase<SupplierFacade>
    {
	    private SupplierRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public SupplierRepository Repository { get { return m_repository; } }

        public SupplierFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new SupplierRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new SupplierRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
    public partial class TerritoryFacade : GrayParrot.Data.ADONET.FacadeBase<TerritoryFacade>
    {
	    private TerritoryRepository m_repository = null;
		private DbContext m_context = null;
		private DbConnectionFactory m_factory = null;
	    private IUnitOfWork m_unitOfWork = null;

		public TerritoryRepository Repository { get { return m_repository; } }

        public TerritoryFacade()
        {
        }

        public override void Initialize()
        {
            m_factory = new DbConnectionFactory("NorthWindCn");

            // during start of the current session
            m_context = new DbContext(m_factory);

			m_repository = new TerritoryRepository(m_context);
        }

		public override void Initialize(IDbContext context)
        {
		    m_repository = new TerritoryRepository((DbContext)context);
        }

		public override void Dispose()
        {
		    if(m_factory != null)
			{
			   m_factory = null;
			}

            if (m_context != null)
            {
                m_context.Dispose();

                m_repository = null;
            }
        }
	}
}

